title: Java print, Letter format instead of A4
body: <p>As far as I know, <code>Java</code> Print uses the OS (windows) settings (format type) when sending a task to the printer. However, no matter how I change my code and despite the fact that all my settings are set for an A4, after sending a task to the printer it always accepts the task with a Letter format and I get a printer out of paper error. Although, when I press the restart printing button on the printer it prints out the file correctly. I have tried a lot of different methods from StackOverflow but they didn't really work out. I tried my application on another PC connected to the same model of printer - same problem. Maybe I'm missing something small or looking for the solution in the wrong place?</p>
  
  <p>This is a piece of my code:</p>
  
  <pre><code>private PrinterJob createPDFPrinterJob(PDDocument pdfDocument) {
  
      PrinterJob printJob = PrinterJob.getPrinterJob();
  
      PageFormat pageFormat = new PageFormat();
      pageFormat.setOrientation(PageFormat.PORTRAIT);
  
      Paper paper = new Paper();
      pageFormat.setPaper(paper);
  
      try {
          printJob.setPrintable(new PDPageable(pdfDocument), pageFormat);
      }
      catch(PrinterException ex) {
          ex.printStackTrace();
      }
  
      return printJob;
  }
  </code></pre>