title: PDF header signature not found
body: <p>I have below <code>iText</code> pdf creation code, basically I need <code>PdfStamper</code> in my later part of code to render html content but it is throwing exception <code>InvalidPdfException</code> while creating <code>PdfStamper</code>:</p>
  
  <pre><code>public static void main(String[] args) throws IOException, DocumentException {
  
          String TEMP_PDF = "temp.pdf";
          String RESULT = "output1.pdf";
          OutputStream osTemp = null;
          OutputStream osResult = null;
          PdfWriter writer = null;
          PdfReader reader=null;
          PdfStamper stamper=null;
          Document document = new Document(PageSize.LETTER);
  
          try {
              osTemp = new FileOutputStream(TEMP_PDF);
              osResult = new FileOutputStream(RESULT);
              writer = PdfWriter.getInstance(document, osTemp);
              reader = new PdfReader(TEMP_PDF);
              stamper = new PdfStamper(reader, osResult);
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              osTemp.close();
              osResult.close();
              writer.close();
              reader.close();
              stamper.close();
          }
      }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>public void createPdf(String file) throws DocumentException, IOException {
          Document document = new Document(PageSize.LETTER);
          PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(file));
          document.open();
          int[] coords = new int[] {1, 50, 50, 100, 100} ;
          PdfContentByte canvas = pdfWriter.getDirectContent();
          ColumnText columnText = new ColumnText(canvas);
          String css = "";
          //llx, lly, urx, ury
          columnText.setSimpleColumn(coords[1], coords[2], coords[3], coords[4]);
          ElementList elements = XMLWorkerHelper.parseToElementList("&lt;html&gt;&lt;body&gt;&lt;b&gt;Bold text&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;", css);
          for (Element element : elements) {
              columnText.addElement(element);
          }
          columnText.go();
          document.close();
      }
  </code></pre>