如何打印显示printDialog的PDF?
现在我对这段代码很感兴趣:
public static void print2(){
InputStream is = null;
try
{
PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob printerJob = defaultPrintService.createPrintJob();
File pdfFile = new File(TEMPPDF);
is = new BufferedInputStream(new FileInputStream(pdfFile));
Doc simpleDoc = new SimpleDoc(is, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
printerJob.print(simpleDoc, null);
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}
但是我会显示打印对话框:
public static void print2(){
InputStream is = null;
try
{
PrinterJob pj = PrinterJob.getPrinterJob();
//pj set pdf file to print ...?
pj.printDialog();
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}