title: control the size of the panel on printed page
body: <p>i want to print jpanel with two tables . Two problems i faced , the first one is the Accuracy of the printed image is not very good. the second how can i control the size of the jpanel on the printed page?? </p>
  
  <p>here is an image of the printed page using xps viewer(the accuracy is not good)
  <img src="https://i.stack.imgur.com/hCzq2.png" alt="enter image description here"></p>
  
  <p>is there away to make the printed image with this accuracy <img src="https://i.stack.imgur.com/egJU1.png" alt="enter image description here">like this</p>
  
  <p>and this is the code:</p>
  
  <pre><code>     PrinterJob printjob = PrinterJob.getPrinterJob();
      printjob.setJobName(" TESSCO CUSTOMER CARD ");
  
      Printable printable = new Printable() {
  
              public int print(Graphics pg, PageFormat pf, int pageNum) {
  
                      if (pageNum &gt; 0) {
                              return Printable.NO_SUCH_PAGE;
                      }
  
                      Dimension size = jPanel1.getSize();
                      BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
  
                      jPanel1.print(bufferedImage.getGraphics());
  
                      Graphics2D g2 = (Graphics2D) pg;
                      g2.translate(pf.getImageableX(), pf.getImageableY());
                      g2.drawImage(bufferedImage, 0, 0, (int) pf.getWidth(), (int) pf.getHeight(), null);
  
                      return Printable.PAGE_EXISTS;
              }
      };
  
      Paper paper = new Paper();
      paper.setImageableArea(0, 0,700,890);
      paper.setSize(700,890);
  
      PageFormat format = new PageFormat();
      format.setPaper(paper);
      format.setOrientation(PageFormat.LANDSCAPE);
  
      printjob.setPrintable(printable, format);
      if (printjob.printDialog() == false)
              return;
  
      try {
              printjob.print();
      } catch (PrinterException ex) {
              System.out.println("NO PAGE FOUND." + ex);
  
      }
  </code></pre>