title: Java Formatter receipt printing issue
body: <p>I am designing a receipt to print out in Java using the PrinterJob class.</p>
  
  <p>I need some advice.</p>
  
  <p>Based on the example I saw here.</p>
  
  <p><a href="http://www.javadocexamples.com/java_source/__/re/Receipt.java.html" rel="nofollow noreferrer">http://www.javadocexamples.com/java_source/__/re/Receipt.java.html</a></p>
  
  <p>How do I store the output given in the example above in a jTextPanel?
  I will then print out the text content inside the jTextPanel using the PrinterJob class.</p>
  
  <p>I want to get the following output when I print out the text content inside the jTextPanel from my POS printer.</p>
  
  <p><img src="https://i.stack.imgur.com/fQqiw.png" alt="enter image description here"></p>
  
  <p>Below are the codes I have so far.</p>
  
  <pre><code>String s = String.format("Item Qty Price", "%-15s %5s %10s\n");
          String s1 = String.format("---- --- -----","%-15s %5s %10s\n");
          String output = s + s1;
  
          jTextPane1.setText(output);
  
          PrinterJob printerJob = PrinterJob.getPrinterJob();
          PageFormat pageFormat = printerJob.defaultPage();
          Paper paper = new Paper();
          paper.setSize(180.0, (double) (paper.getHeight() + lines * 10.0));
          paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight() - margin * 2);
          pageFormat.setPaper(paper);
          pageFormat.setOrientation(PageFormat.PORTRAIT);
          printerJob.setPrintable(jTextPane1.getPrintable(null, null), pageFormat);
          printerJob.print();
  </code></pre>
  
  <p>Any advice on how can I proceed?</p>