Jspdf: Create a pdf from a pdf template

Created on 16 Dec 2014  路  10Comments  路  Source: MrRio/jsPDF

I'm looking to generate a pdf from an existing pdf "template". For example, the pdf "template" would have the layout, text, and "fields" -- all that would be left to do is fill in "fields" with data.

I would like to populate these fields with the appropriate data from a mongo collection, and generate a new pdf from it. Is this possible with this package?

For example, the following is part of a pdf document, the "fields" need to be populated with data I get from a collection:
screen shot 2014-12-16 at 12 52 42 pm

Most helpful comment

Just want to upvote this request. somehow using an existing PDF and allowing jsPDF to write on top of it.

All 10 comments

Just want to upvote this request. somehow using an existing PDF and allowing jsPDF to write on top of it.

This would be a huge improvement. Users could change templates without having to rewrite the entire javascript.

In the mean time, I found that using a combination of the following works great:

(1) PDFtk server to do the form fills of an existing template,

(2) a wrapper around PDFtk server for javascript -- in my case since I'm using Meteor I'm using pascoual/meteor-pdftk,

(3) and standard oozcitak/xmlbuilder-js to build the XFDF file used to populate the pdf with data.

It's actually straight forward when you get it all working. Not as easy as a single package to do everything of course, but when there's nothing else, you make it work.

From my research, the javascript/linux libraries to do pdf form fills are extremely limited. PDFtk is it in terms of quality and features as far as I know. I think there is one other package, the name escapes me at the moment, and from what I read it doesn't always work, etc. I think the wait on this and other packages to do form fill will be a long one I'm afraid.

YMMV of course, but since adopting the approach above, I've had zero issues.

Good luck.

My current hack is to let the user fill out a form on a page, then those fields to load up javascript/localStorage variables which get fed into the PDF being generated. Then I add content based on if statements. I'm able to generate forms with custom content that way.

I thought about this approach, but I wanted more control over the interface or input, so I went the the web front end to populate the Mongo database. Then use this data to do a form full a long with business logic.

Any updates on this feature yet?

Any updates?

would be great to have this feature.

@rexbarkdoll, I am not sure I understand what you were doing. Is the "pdf being generated" an existing pdf that gets some fields overlayed, or from scratch? I think this issue is about the former.

Duplicate of #131

Was this page helpful?
0 / 5 - 0 ratings