List of utility methods to do Printer Usage
void | print(PrintService printService, byte[] pdf)final DocPrintJob job = printService.createPrintJob(); final Doc doc = new SimpleDoc(pdf, DocFlavor.BYTE_ARRAY.PDF, null); final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new Copies(1)); aset.add(MediaSizeName.ISO_A4); aset.add(Sides.ONE_SIDED); job.print(doc, aset); |
void | refreshPrinterList() refresh Printer List Class<?>[] classes = PrintServiceLookup.class.getDeclaredClasses(); for (Class<?> classe : classes) { if (classe.getName().equals("javax.print.PrintServiceLookup$Services")) { sun.awt.AppContext.getAppContext().remove(classe); break; |
void | showAttributes(PrintRequestAttributeSet aset) show Attributes Attribute tab[] = aset.toArray(); for (int i = 0; i < tab.length; i++) { Attribute attr = tab[i]; System.out.println(" - " + i + ". " + attr.getName() + " " + attr.toString()); |
void | testSPS() Test Stream Print Services PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); PrintService[] pss = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, pras); for (int i = 0; i < pss.length; i++) { PrintService ps = pss[i]; String name = ps.getName(); if (name.indexOf("PDF") != -1 || name.indexOf("Acrobat") != -1) { System.out.println("----"); System.out.println(ps); ... |
int | validateDPI(int dpi) Validates the dpi value. if (dpi <= 0) dpi = ResolutionSyntax.DPI; if (dpi <= 0) dpi = DEFAULT_DPI; return dpi; |