Hello I'm tring to print directly a PDF file using PDFBox 2, but if I print the file using pdfbox this is printed rotated by 90° I have the same issue using an A4 standard printer and also a label printer. If I try to print using Adobe Reader the same pdf file is printed correctly.
I'm using this code:
static void printPDF(String completeFileName, String printerName) {
try {
PDDocument doc = PDDocument.load(new FileInputStream(completeFileName)); //read pdf file.
javax.print.PrintService[] service = PrinterJob.lookupPrintServices();
DocPrintJob docPrintJob = null;
int count = service.length;
for (int i = 0; i < count; i++) {
if (service[i].getName().trim().equalsIgnoreCase(printerName)) {
docPrintJob = service[i].createPrintJob();
i = count;
}
}//for
PrinterJob pjob = PrinterJob.getPrinterJob();
pjob.setPrintService(docPrintJob.getPrintService());
pjob.setJobName("job");
PDFPageable pAble = new PDFPageable(doc);
pjob.setPageable(pAble);
//pjob.printDialog();
pjob.print();
} catch (Exception er) {
er.printStackTrace();
}
}
I don't know where I made the error... I don't find how disable autorotate (in pdfbox v2).
Best regards Fabio