bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.7k stars 2.04k forks source link

PDF Templating (was: Create a pdf from a pdf template) #156

Open aadamsx opened 9 years ago

aadamsx commented 9 years ago

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 guess like a fill Forms scenario...

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

All the pdf packages I've came across seem to generate pdfs, but none seem to generate a pdf from a template populated with data I provide.

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

lvarayut commented 9 years ago

+1

aadamsx commented 9 years ago

@lvarayut, just use PDFtk server (command line)... it will allow for form fills.

You'll need to build a FDF or XFDF file to populate the PDF, but you can use xmlbuilder for that (can use JSON too).

lvarayut commented 9 years ago

@aadamsx Thanks for your information. I will try it soon.

jthoenes commented 9 years ago

Currently this feature is missing in PDFkit, the underlying PDF engine. So it's probably not going to be done soon.

See https://github.com/devongovett/pdfkit/issues/227

okdistribute commented 9 years ago

@aadamsx I just built something using pdftk and it works well, but it'd be nice if we could do this client-side! Thanks @jthoenes for the link

aadamsx commented 9 years ago

you'd have to have some sort of processor (which is what pdftk is) uploaded to the client (the browser). Since your idea is that this would all live in the browser, the processor might have to either be a plug in or written in javascript.

If this was a browser in a older iphone for example, it might be that processing on the server and outputting to the browser might be faster.

I saw somewhere an approximation of the pdftk codebase I think written in php (not sure really). Someone would need to spend some time doing the code conversion to javascript.

As far as I know, pdftk is the only real solution for form fills (robust) on unix based systems. I think iText can be used for windows based systems.

krhebbar commented 8 years ago

+1

mgaurav92 commented 8 years ago

@jthoenes , any update on this functionality? @karissa , can you please share how you made it work?

thanks in advance.

pici-masp commented 7 years ago

I would also love this feature

aadamsx commented 7 years ago

It's not going to happen in the package. You must use PDFtk.

vodera commented 4 years ago

How did you use PDFtk to generate that kind of a form @aadamsx

vodera commented 4 years ago

Is there a better way to do this? I am 3 years behind, trying to generate this kind of a form using PDFMAKE pdf