How to edit or write on existing PDF with Ruby?

you have to definitely check out Prawn gem, by which you can generate any custom pdf files. You can actually use prawn to write in text into existing pdfs by treating the existing PDF as a template for your new Prawn document.

For example:

filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf"
Prawn::Document.generate("full_template.pdf", :template => filename) do
  text "THis content is written on the first page of the template", :align => :center
end

This will write text onto the first page of the old pdf.

See more here:
http://prawn.majesticseacreature.com/manual.pdf

Leave a Comment