我正在尝试使用PDFbox库打印PDF。但是合成的印刷品旋转了90度。页面尺寸为70mm x 17mm,但打印长度为17mm x 70mm。
String filename = dest;
PDDocument document = PDDocument.load(new File (filename));
PrintService myPrintService = PrintServiceLookup.lookupDefaultPrintService();
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(document));
job.setPrintService(myPrintService);
if(job.printDialog())
job.print();
document.close();
谢谢。
答案 0 :(得分:0)
您可以将Orientation
枚举传递给PDFPageable
构造函数:
job.setPageable(new PDFPageable(document, Orientation.PORTRAIT) );
由于您使用的是非标准纸张,因此Orientation.AUTO
的默认方向值是将较短边缘解释为顶部和底部。