Java仅在pdf文件中打印第一页

时间:2019-04-30 15:12:50

标签: java printing

a无法打印文件中的所有页面,他仅打印第一页,请帮助

PrintService printService = 
PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob printJob = printService.createPrintJob();
PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage();

PDDocument pdDocument = PDDocument.load(new File("BONE.pdf"));
PDFPrintable pdfPrintable = new PDFPrintable(pdDocument);
int number = pdDocument.getNumberOfPages() ;
Book book = new Book();
book.append(pdfPrintable, pageFormat);
SimpleDoc doc0 = new SimpleDoc(book,DocFlavor.SERVICE_FORMATTED.PAGEABLE , null);
printJob.print(doc0, null);

0 个答案:

没有答案