title: iText: PDF Generation. One Template. More Inputs. One Output
body: <p>i try to generate a pdf with itext. First i read in a existing template and stamp the formulars in the method <code>stampFormular(Formular formular, PdfStamper stamper)</code>. The stamp method works. But i have a problem, with adding more formulars to the output file.</p>
  
  <p>I want to stamp for each Formular the PDF Template "yellow". So i tried it with, the <code>document.add()</code>, but that doesn't work. So i tried to do this with pdf writer. But that doesn't work to. Any idea how i can stamp the pdf template with the one formular data, make a new page and stamp the same pdf template with the next formular data.</p>
  
  <pre><code>public static File createForm(List&lt;Fomular&gt; formulars) {
          Document document = new Document();
          File pdf = null;
  
          document.open();
  
          try {
              PdfReader pdfTemplate = new PdfReader('YELLOW');
              PdfStamper stamper = new PdfStamper(pdfTemplate,
                      new FileOutputStream("output.pdf"));
              PdfWriter writer;
              for (Formular f : formulars) {
                  stamper = stampFormular(f, stamper);
                  writer = stamper.getWriter();
                  writer.newPage();
              }
  
              stamper.close();
              pdfTemplate.close();
              pdf = new File("output.pdf");
              Desktop.getDesktop().open(pdf);
          } catch (DocumentException | IOException e) {
              e.printStackTrace();
          }
          return pdf;
      }
  </code></pre>