title: Printing PDF or PNG in POS Thermal printer with java
body: <p>I Everyone. I have a problem printing ticket with java. I generated ticket with jasper and then I need to print it in POS Thermal printer. I try to print PDF and the result got 
  <a href="https://i.stack.imgur.com/Rwng8.jpg" rel="nofollow noreferrer">Wrong Format</a>
  Then I convert pdf to png with pdfbox but the image print too small. 
  How can I print correctly? Is there any way to print PDF for POS Thremal Printer correctly or fill and increase the PNG Image?  </p>
  
  <p><a href="https://i.stack.imgur.com/257nj.jpg" rel="nofollow noreferrer">Print PNG too small</a></p>
  
  <p>Printing from Adobe reader directly to my POS Thermal Printer, I had the correctly ticket.
  <a href="https://i.stack.imgur.com/W7fMz.jpg" rel="nofollow noreferrer">Correct from Adobe Reader</a></p>
  
  <p>Here's part of my code: </p>
  
  <pre><code>PDDocument document = PDDocument.load(new File(pathFile+".pdf"));
              PDPage pd;
  
              PDFRenderer pdfRenderer = new PDFRenderer(document);
  
              for (int page = 0; page &lt; document.getNumberOfPages(); ++page)
              {
                pd = document.getPage(page);
                BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
                ImageIOUtil.writeImage(bim, pathFile +".png", 300);
  
              }
              document.close();
  
              FileInputStream is = new FileInputStream(pathFile+".png");
  
              DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
              DocPrintJob job = mPrinter.createPrintJob();
              Doc doc = new SimpleDoc(is, flavor, null);
  
              job.print(doc, null);
  
              is.close();
  </code></pre>