pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Imran Akbar <imranakba...@gmail.com>
Subject PDFBox Alignment for Existing PDF
Date Sun, 09 Nov 2014 08:12:17 GMT
Hi all,

I am trying to load a pdf from URL/FIle and do a silent print by choosing
the default printer. it prints but the printed output is having issues in
the alignment, if documents contains Footers, they are getting stripped off
and not getting printed. is there a way to set the printing properties
before we print the document when loading an existing document. Please find
my below code,

******

public class PrintPdf {

    public static PrintService choosePrinter() {
        PrinterJob printJob = PrinterJob.getPrinterJob();
        if (printJob.printDialog()) {
            return printJob.getPrintService();
        } else {
            return null;
        }
    }

    public static void printPDF(String fileName, PrintService printer)
            throws IOException, PrinterException {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintService(printer);

        PDDocument doc = PDDocument.load(fileName);

        doc.silentPrint(job);
    }

    public static void main(String[] args) throws IOException,
PrinterException {

        printPDF("http://localhost/IS1330900025_3705.pdf", choosePrinter());
    }

}

****

- Imran

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message