title: copying a page n number of times with pdfbox
body: <p>I have made a single page pdf template file.  I then use pdfbox to create a pdf with "n" number of pages (depending on report size).  I want all "n" of these pages to be the page from the template pdf file.  What is the best way to get all "n" pages to be a copy of that page?  Here is my current code:</p>
  
  <pre><code>PDDocument document = null;
  try {
      document = PDDocument.load(WestfieldClientReportApp.class.getResource("/com/dramble/resources/template.pdf"));
  } catch (IOException ex) {
      Logger.getLogger(WestfieldClientReportView.class.getName()).log(Level.SEVERE, null, ex);
  }
  
  PDPage templatepage = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
  
  int n = 0;
  while (n &lt; numPages) {
      n++;
      document.importPage(templatepage);
  }
  </code></pre>
  
  <p>The problem is when I have large result sets.  I'll open the pdf, it will show as 11 pages, the first 2 pages look great, but when I scroll to the 3rd page, Acrobat errors, though the template page seems to be there, but without my report data on it.  I figure the problem is probably with the code above.  Any ideas?  Thanks.</p>