When I print a PDF using the below code, the PDF appears smaller in the
result than the original file.  How do I solve this?

Input: http://joshnankin.com/input.pdf
What prints: http://joshnankin.com/whatPrints.pdf


Code:

        PDFPrinter printer = new PDFPrinter(PDDocument.load(new
File("input.pdf")));

        PrinterJob job = PrinterJob.getPrinterJob();
        PageFormat pf = job.defaultPage();
        Paper paper = new Paper();
        paper.setSize(612, 792);
        double margin = 0;
        paper.setImageableArea(margin, margin, paper.getWidth() - margin,
paper.getHeight() - margin);

        pf.setPaper(paper);
        job.setPageable(printer.getPageable());
        job.setJobName("test");
        job.printDialog();
        try {
            job.print();
        } catch (PrinterException e) {
            System.out.println(e);
        }

Reply via email to