title: Insert data into PDF, filled in an online form, on submit action
body: <p>First of all my apologies to all the people who think this question is a repeated one or they find a similar question to this.</p>
  
  <p>I am working on a project in which I have an online form and some PDFs stored on the server. </p>
  
  <p><strong>Functionality</strong></p>
  
  <p>On the submit action I have to get the data from the form, fill it to the copy of PDF and finally download it.</p>
  
  <p><strong>Approach</strong></p>
  
  <p>I followed these steps to achieve this functionality:</p>
  
  <ul>
  <li>Converted the pdfs to html with this <a href="http://www.pdfdownload.org/free-pdf-to-html.aspx" rel="nofollow noreferrer">http://www.pdfdownload.org/free-pdf-to-html.aspx</a> online tool.</li>
  <li>Embedded the html with form variables and regenerated the PDFs with <a href="http://www.tufat.com/s_html2ps_html2pdf.htm" rel="nofollow noreferrer">this</a> library / dompdf library.</li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <ul>
  <li>The approach is a brute force one as the html generated are far away from the real ones. So lot of effort is wasted in adjusting the html.</li>
  <li>The process is so slow and not reliable as most of the time I get memory error or some other issues.</li>
  </ul>
  
  <p>I need to to automate this process. What I have found through searching is I should create an FDF file that contains my variable and pass it to the PDF using some library and then download it.</p>
  
  <p>I am able to create the FDF file but missing any library in PHP (I found one in JAVA) that I can use to create the PDF and download it. One library that I found is <a href="http://www.accesspdf.com/pdftk/" rel="nofollow noreferrer">pdf tool kit</a> but that is a command line tool and I am not able to use it on the server at run time and download the PDF file.</p>
  
  <p>Anybody having done this before please help.</p>
  
  <p>(Sorry for this long post)</p>
  
  <p>Thanks,</p>
  
  <p>Madhup</p>