Chakreshwar Sharma
Chakreshwar Sharma

Reputation: 2610

Fill a PDF form with default data

I am working on editing a PDF form/template in Ruby On Rails application. I want to populate some of form fields with data from database and make few fields editable to take the input from user. I found PDFtf but I read that this is very old library and hardly works with the new Linux/Mac versions. I checked https://www.adamalbrecht.com/blog/2014/01/31/pre-filling-pdf-form-templates-in-ruby-on-rails-with-pdftk/

Upvotes: 3

Views: 612

Answers (1)

K J
K J

Reputation: 11847

Form fields are in FDF/XFDF files (very similar to a PDF as they are the data overlay) they are old hat but in constant use daily the library you link to is maintained this year and last stable release was October 2020 it is the old proprietary Adobe Forms methodology that is very much stable since turn of the century.

see https://github.com/jkraemer/pdf-forms#fdfxfdf-creation for how it uses PDFtk to adjust the FDFs

It does not matter which language or library you use the data is best kept static . I can write PDF via cmd so i guess fdf as text or xfdf as xml is just as easy.

best kept in simpler FDF format since for users its easiest to use a PDF/FDF reader / forms modifier such as Acrobat, Tracker or Foxit etc.

You can use any of those API s or just as simply use a find and replace method but its easiest to use a paid tool like PDFTK that can resolve the backgound mathematics. $79 for your server version will pay for itself quickly. Even $3 for a personal pro version is a bargain.

For a Ruby specific method using PDFtk last updated 28 Dec 2021 see https://github.com/ruby-journal/nguyen

Upvotes: 3

Related Questions