title: How to edit or write on existing PDF with Ruby?
body: <p>I have a couple of PDF template files with complex content and several blank regions/areas in them. I need to be able to write text in those blank regions and save the resulting PDFs in a folder.</p>
  
  <p>I googled for answers on this question quite intensively, but I didn't find definite answers. One of the better solutions is <a href="http://pdf-toolkit.rubyforge.org/" rel="noreferrer">PDF::Toolkit</a>, but it would require the purchase of Adobe Acrobat to add replaceable attributes to existing PDF documents.</p>
  
  <p>The PHP world is blessed with <a href="http://www.setasign.de/products/pdf-php-solutions/fpdi/" rel="noreferrer">FPDI</a> that can be used to simply open a PDF file and write/draw on it over the existing content. There is a <a href="https://github.com/jeremydurham/ruby-fpdi" rel="noreferrer">Ruby port of this library</a>, but the last commit for it happened at the beginning of 2009. Also that project doesn't look like it is widely used and supported.</p>
  
  <p><strong>The question is:</strong> What is the better Ruby way of editing, writing or drawing on existing PDFs?</p>
  
  <p>This question also doesn't seem to be answered on here. These questions are related, but not really the same:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/3148370/prawn-gem-how-to-create-the-pdf-from-an-existing-file-xls">Prawn gem: How to create the .pdf from an *existing* file (.xls)</a></li>
  <li><a href="https://stackoverflow.com/questions/2716148/watermark-existing-pdf-with-ruby">watermark existing pdf with ruby</a></li>
  <li><a href="https://stackoverflow.com/questions/2458472/ruby-library-for-manipulating-existing-pdf">Ruby library for manipulating existing PDF</a></li>
  <li><a href="https://stackoverflow.com/questions/4869879/how-to-replace-a-word-in-an-existing-pdf-using-ruby-prawn">How to replace a word in an existing PDF using Ruby Prawn?</a></li>
  </ul>