The PAGEABLE flavor so we need to pass in a Pageable object - this is the PDFParser object, which implements Pageable. How you specify the document depends on what sort of "flavor" you specified. It's double-sided, which pages to print and so on. Just like the PrintRequestAttribute helps to specify the type of printer you're looking for, the DocAttribute specifies details about the print job itself - the name of the the printjob, whether Now we need to specify the document and the job attributes. PrinterJob job = PrinterJob.getPrinterJob() Throw new IllegalStateException("No Printer found") PrintService ps = PrintServiceLookup.lookupPrintServices(flavor, patts) PrintRequestAttributeSet patts = new HashPrintRequestAttributeSet() Here's what the code would look like if we were looking for a printer thatĭocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE You also get to specify a set of PrintRequestAttributes to qualify your search for a printer - for instance, you may need a printer thanĬan print double-sided or that can print to A3, and there are attributes for each In the case of a PDF it's a PAGEABLE object, which means that the contents are a (potentially) multi-page object which In order to chose a printer you must first know what you're printing, which meansĬhoosing a DocFlavor. All the code below assumes you've imported, javax.print and its sub-packages. In Java is like printing any other type of document, but we'll go through all the Of these steps, the only PDF-specific one is the last, so in practice printing a PDF
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |