jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

Create a pdf from a pdf template

Open aadamsx opened this issue 11 years ago • 11 comments

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

aadamsx avatar Dec 16 '14 18:12 aadamsx

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

rexbarkdoll avatar Jan 24 '15 08:01 rexbarkdoll

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

z3rodo7com avatar Jan 29 '15 20:01 z3rodo7com

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.

aadamsx avatar Jan 29 '15 21:01 aadamsx

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.

rexbarkdoll avatar Jan 29 '15 23:01 rexbarkdoll

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.

aadamsx avatar Jan 30 '15 16:01 aadamsx

Any updates on this feature yet?

enabek avatar Mar 03 '17 17:03 enabek

Any updates?

shamoh19 avatar Apr 12 '17 05:04 shamoh19

would be great to have this feature.

gjulivan avatar Jun 18 '17 06:06 gjulivan

@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.

fatso83 avatar Nov 09 '17 15:11 fatso83

Duplicate of #131

Uzlopak avatar Feb 24 '18 21:02 Uzlopak

Soy un comentario

FranckStgo avatar Sep 10 '22 23:09 FranckStgo