title: FPDF Duplicate a modified page
body: <p>I am using FPDF <a href="http://www.fpdf.org/" rel="nofollow">http://www.fpdf.org/</a> and  FPDI <a href="http://www.setasign.com/products/fpdi/about/" rel="nofollow">http://www.setasign.com/products/fpdi/about/</a></p>
  
  <p>I have a 2 page pdf file.
  I need to import the first page to a new pdf and add two texts on that first page. Then I need to duplicate that page so that the resulting pdf may contain two pages of same content. </p>
  
  <p>The code I am using is</p>
  
  <pre><code>require_once ('fpdf/fpdf.php');
  require_once ('fpdf/fpdi.php');
  
  $file = "myexistingpdf.pdf";
  
  $pdf = &amp;new FPDI();
  $pdf -&gt; AddPage();
  
  $pagecount = $pdf -&gt; setSourceFile($file);
  $tpl = $pdf -&gt; importPage(1);
  $pdf -&gt; useTemplate($tpl);
  
  $pdf -&gt; SetY(116);
  $pdf -&gt; SetX(-300);
  $pdf -&gt; SetFont('Times', 'B', 9);
  $pdf -&gt; Cell(0, 10, "Hello World", 0, 0, 'C');
  
  $pdf -&gt; SetY(22);
  $pdf -&gt; SetX(-358);
  $pdf -&gt; SetFont('Times', 'B', 8);
  $pdf -&gt; Cell(0, 10, "Date:", 0, 0, 'C');
  
  $pdf -&gt; Output("pdf.pdf", "I");
  </code></pre>
  
  <p>This works fine and I am getting the first page of existing pdf imported to the new pdf and is getting modified, but I am not sure how can I duplicate this modified page without duplicating the above codes. Any idea how to do it ?</p>