title: JPanel Pdf generation with iText very slow
body: <p>I have a Java Swing app in which the user can generate a PDF file from a JPanel.
  But it takes more than 6304 milliseconds to generate that single JPanel screenshot.</p>
  
  <p>Here is the code I use :</p>
  
  <pre><code>private void printStamp()
  {
    long startTime=System.currentTimeMillis();
  
    if ( panelPhoto.isALabelSelected == false )
      {
         notificationErrorPopup("No stamp is selected !");
      }
    else
      {
      Document document = new Document();
      try
        {
          PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
                              "C:\\Users\\Admin71\\Desktop\\test1.pdf"));
          writer.setCompressionLevel(0);
          document.open();
          PdfContentByte contentByte = writer.getDirectContent();
          PdfTemplate template = contentByte.createTemplate(panelBasTotal.panelShow.getWidth(),
                                  panelBasTotal.panelShow.getHeight());
          Graphics2D g2 = template.createGraphics(panelBasTotal.panelShow.getWidth(),
                                  panelBasTotal.panelShow.getHeight());
          g2.scale(1.0d, 1.0d);
          panelBasTotal.panelShow.printAll(g2); // also tried with jp.paint(g2)
          panelBasTotal.panelShow.addNotify();
          panelBasTotal.panelShow.validate();
          g2.dispose();
          contentByte.addTemplate(template, 0, 0);
        }
      catch (Exception e)
        {
          e.printStackTrace();
        }
      finally
        {
          if ( document.isOpen() )
          {
              document.close();
          }
        }
      System.out.println("Duration of Pdf printing :" + (System.currentTimeMillis()-startTime));
    }
  }
  </code></pre>
  
  <p>Am I doing something wrong or is this delay normal ?</p>