用JDK5.0的,代码如下:
public class printWord
{
public static void main(String[] args)
{
String filename = "c:/job-cec-action-download-pid-48168-tid-10290-aid-2403.htm";
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
System.out.println(DocFlavor.hostEncoding);
System.out.println(flavor);
PrintService printService[] = PrintServiceLookup.lookupPrintServices(null, pras);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, null, pras); if (service != null)
{
DocPrintJob job = service.createPrintJob();
FileInputStream fis = null;
try
{
fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (PrintException e)
{
e.printStackTrace();
} } }只能打印图片,不能打印其它的文件,也不抱错,就是打印出来的文件是空白的
帮我大哥大姐们想想思路