title: PHP import PDF form and output PDF form
body: <p>I have a fillable PDF form, I need to write some numbers on PDF using PHP (not necessarily into form fields, but just on PDF) and then output PDF again with all fillable fields that original document had.</p>
  
  <p>FPDI and FPDF are doing the job, but PDF fillable fields will be lost during the process.</p>
  
  <p><a href="https://stackoverflow.com/questions/8501117/php-and-importing-pdf-with-forms/39349287">Here</a> is suggested mpdf, most of mpdf examples I found are about making new PDF files from HTML. There is <a href="http://www.mpdfonline.com/repos/mpdfmanual.pdf" rel="nofollow noreferrer">mpdf manual</a>, but I'm not sure what functions should solve my problem.</p>
  
  <p>Code below does the job, but as said all the PDF form fields will dissapear.</p>
  
  <pre><code>include('FPDF-master/fpdf.php'); 
  include('FPDI1_6_1/fpdi.php');
  //include('mpdf60/mpdf.php');
  
  $pdf = new FPDI();
  
  $pdf-&gt;AddPage(); 
  $pdf-&gt;setSourceFile('myfillableform.pdf'); 
  $tplIdx = $pdf-&gt;importPage(1); 
  $pdf-&gt;useTemplate($tplIdx, 0, 0); 
  
  $pdf-&gt;SetFont('Times', 'B'); 
  $pdf-&gt;SetTextColor(0,0,0); 
  $pdf-&gt;SetXY(140, 45);
  $pdf-&gt;Write(0, $someNumber); 
  $pdf-&gt;Output("newfillableform_with_number.pdf", 'F'); 
  </code></pre>