Example usage for org.apache.pdfbox.printing PDFPrintable PDFPrintable

List of usage examples for org.apache.pdfbox.printing PDFPrintable PDFPrintable

Introduction

In this page you can find the example usage for org.apache.pdfbox.printing PDFPrintable PDFPrintable.

Prototype

public PDFPrintable(PDDocument document, Scaling scaling) 

Source Link

Document

Creates a new PDFPrintable with the given page scaling.

Usage

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) {
            }
        }
    }
}