title: Itext PdfSmartCopy getting Null pointer Exception
body: <p>I'm now using Itext PdfSmartCopy. I'm adding some business contents to a document object with XMLworker. Then I declared a reader (for a pdf file to be concatenated to this document object). Then I'm calling PdfSmartCopy with the same document object and output file stream as arguments. Then I'm using conventional steps to copy the page to the document,</p>
  
  <pre><code>addHTML(document, htmlStringToBeAdded);
  document.newPage();
  com.itextpdf.text.pdf.PdfCopy copy = new com.itextpdf.text.pdf.PdfSmartCopy(document, new FileOutputStream("c:\\pdf_issue\\bad_itext3.pdf"));
  com.itextpdf.text.pdf.PdfReader reader=new com.itextpdf.text.pdf.PdfReader("c:\\pdf_issue\\bad1.pdf");
   // loop over the pages in that document
   n = reader.getNumberOfPages();
    for (int page = 0; page &lt; n; ) {
                  copy.addPage(copy.getImportedPage(reader, ++page));
              }
  copy.freeReader(reader);
      reader.close();
  </code></pre>
  
  <p>But I'm getting Null pointer exception at getPageReference? What's the issue?</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at com.itextpdf.text.pdf.PdfWriter.getPageReference(PdfWriter.java:1025)
      at com.itextpdf.text.pdf.PdfWriter.getCurrentPage(PdfWriter.java:1043)
      at com.itextpdf.text.pdf.PdfCopy.addPage(PdfCopy.java:356)
      at com.jci.util.PdfTest.main(PdfTest.java:627)
  </code></pre>
  
  <p>But this piece works well if I use a new document object ie without adding business contents.</p>