title: PDFBOX printing issue: Printed PDF unexpectedly rotated 90 degrees and incorrect size
body: <p>I am using PDFBox 2.0.0-SNAPSHOT to print the PDF in printer(both HW &amp; virtual), and it printing work but printed PDF unexpectedly rotated 90 degrees and incorrect size.</p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/33134610/testPrintPDF/examplePDF.pdf" rel="nofollow">example PDF download link</a></p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/33134610/testPrintPDF/printedPDF%20by%20latest%20version.pdf" rel="nofollow">printed result PDF download link</a></p>
  
  <p>Following is my code snippet:</p>
  
  <pre><code>PrinterJob printJob = PrinterJob.getPrinterJob();
  PrintService prsvc = getPrinterServiceByName(PrinterName);
  printJob.setPrintService(prsvc);
  
  PDDocument pdfdoc = PDDocument.load(PdfFile);
  printJob.setPageable(new PDPageable(pdfdoc, printJob));
  
  printJob.print();
  pdfdoc.close();
  </code></pre>
  
  <p>Now I have been updated with the latest PDFBox 2.0.0-SNAPSHOT version,
  and use <code>PDFPrinter</code> constructor to print PDF.And add <code>ImageableArea</code> to define paper imageable area using custom format.But issue still existed. See below:</p>
  
  <pre><code>PrinterJob printJob = PrinterJob.getPrinterJob();
  PrintService prsvc = getPrinterServiceByName(PrinterName);
  printJob.setPrintService(prsvc);
  
  PDDocument  document = PDDocument.load(PdfFile);
  
  Paper paper  = new Paper();
  paper.setSize(1005.0,396.0);  //354.5 x 139.7 mm
  paper.setImageableArea(0, 0, 1005.0, 396.0); //354.5 x 139.7 mm
  
  
  //result 139.7 mm x 354.5 mm. Rotated 90 degrees
  PDFPrinter printer = new PDFPrinter(document,printJob,Scaling.ACTUAL_SIZE,Orientation.PORTRAIT,paper,false,0);
  
  //result 139.7 mm x 354.5 mm. Rotated 90 degrees and context inverted.
  //PDFPrinter printer = new PDFPrinter(document,printJob,Scaling.ACTUAL_SIZE,Orientation.LANDSCAPE,paper,false,0); 
  
  //same result with setting Orientation.LANDSCAPE
  //PDFPrinter printer = new PDFPrinter(document,printJob,Scaling.ACTUAL_SIZE,Orientation.AUTO,paper,false,0); 
  
  PrinterJob job = PrinterJob.getPrinterJob();
  job.setPageable(printer.getPageable());
  
  printer.silentPrint();
  </code></pre>
  
  <p>How do I fix this?</p>