Example usage for org.apache.pdfbox.printing Scaling SCALE_TO_FIT

List of usage examples for org.apache.pdfbox.printing Scaling SCALE_TO_FIT

Introduction

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

Prototype

Scaling SCALE_TO_FIT

To view the source code for org.apache.pdfbox.printing Scaling SCALE_TO_FIT.

Click Source Link

Document

Stretch or shrink the image to fill the page, as needed.

Usage

From source file:PrintUtil.java

License:Apache License

void print() {
    PDDocument doc = null;//w  w w .j  av  a 2 s .  c om
    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) {
            }
        }
    }
}