title: PHP PDF template library with PDF output?
body: <p>Is there any PHP PDF library that can <strong>replace placeholder variables</strong> in an existing PDF, ODT or DOCX document, and generate a PDF file as the end result, without screwing up the layout?</p>
  
  <p>Requirements:   </p>
  
  <ul>
  <li><p>Needs no 3rd party web service</p></li>
  <li><p>Ability to run on shared web hosting would be ideal (no binary installations / packages required)  </p></li>
  </ul>
  
  <p>Mind you, a library that is able to load an existing PDF file and insert text programmatically at a specific position is <strong>not enough</strong> for my use case. </p>
  
  <p>As far as my research shows, there is no library that can do this:</p>
  
  <ul>
  <li><p>TCPDF can only generate documents from scratch</p></li>
  <li><p>FPDI can read existing PDF templates, but can only add contents programmatically (no template variable replacement)</p></li>
  <li><p>There are various DOCX/ODT template libraries out there but they don't output PDF </p></li>
  </ul>
  
  <p><a href="http://www.phpdocx.com/">PHPDOCx</a> claims to be able to do exactly what I need - but they don't offer a trial version and I'm not going to buy a cat in a bag, especially not when there seems to be <em>no other product</em> on the web that does this. I find it hard to believe they can do this without problems - if you have successfully done this using the product, please drop a line here.</p>
  
  <p>Am I overlooking something?</p>
  
  <p>Is there a way to do this using PDF forms? I am creating the source documents in OpenOffice 3.</p>
  
  <p>I may be able to use standard Linux commands (<code>pdftk</code> is available for example, trying that out right now.) </p>
  
  <blockquote>
    <p><strong>Update:</strong> *<em>Argh!</em>* I was called out of the office and the bounty expired in the meantime. Starting a new bounty: As far as my testing shows, no solution works for me perfectly yet.</p>
    
    <p><strong>Update II:</strong> I will be looking the pdftk approach soon, but I am also starting another bounty for one more round of collecting additional input. This question has now seen  1300 rep points in bounties, must be some kind of a record :)</p>
  </blockquote>