Yusuf
Yusuf

Reputation: 31

Populate PDF File from Database

I have a PDF file (Predesigned, I have no control over the design) which allows users to fill in some form fields in Adobe Reader and save the result. I want to automate the process of populating some of the fields (NOT ALL FIELDS), using the following steps:

  1. Fetch data from database.
  2. Open PDF template.
  3. Populate form fields with data.
  4. Save modified file to a separate location on disk.

Restrictions:-

Help will be appreciated :)

enter image description here

Upvotes: 0

Views: 321

Answers (1)

kikito
kikito

Reputation: 52668

  1. Fetch data from database.
  2. Open PDF template.
  3. Populate form fields with data.
  4. Save modified file to a separate location on disk.

Step 1 is basic Ruby on Rails work: create one or multiple Models with each field in the form that you want to fill in, and then fill their table in the database (either with raw sql calls, csv import or manually entering them via the app scaffold views). Then read the models from the database.

Steps 2,3 and 4 cannot be done with ruby on rails alone, you need some extra library capable of manipulating pdf forms.

It seems like you could use the pdf-forms gem might fit the bill. I have personally not used it so I can't comment on how good it is. But it seems it is able to fill up forms, and for each model in your database, fill and save.

Upvotes: 1

Related Questions