List of usage examples for org.apache.pdfbox.printing PDFPrintable PDFPrintable
public PDFPrintable(PDDocument document, Scaling scaling)
From source file:PrintUtil.java
License:Apache License
void print() { PDDocument doc = null;/* w ww .j av a2 s .co m*/ try { doc = PDDocument.load(new File(path)); } catch (IOException e) { e.printStackTrace(); } job.setPrintable(new PDFPrintable(doc, Scaling.SCALE_TO_FIT)); PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); attr.add(Sides.DUPLEX); attr.add(MediaSizeName.ISO_A4); System.out.println("Printing =>" + path); try { job.print(attr); } catch (PrinterException e) { e.printStackTrace(); } finally { if (doc != null) { try { doc.close(); } catch (IOException ignored) { } } } }