Fletcher Moore Fletcher Moore - 5 months ago 64
Javascript Question

How to edit PDFs in Javascript?

Based on my Google and stackoverflow search I'm guessing there are no library for this purpose.

The goal is: store some blank forms on my server. Then present these to the user, who edits the form in the browser with Javascript and submits the form back to the server.

The client wants to reuse parts of an old system (the forms) in which users would download an editable PDF, edit it, and email it back to a secretary. Our users aren't very computer savvy and many don't realize they need to email the forms back, assuming instead the forms somehow get submitted when they save their local changes (or something).

I haven't seen the forms yet, so I cannot assess the viability of an alternative.


I don't know of any Javascript libraries but you can use the FDF/XFDF files to do something like this. The idea is that you basically link your PDF file to an external FDF or XFDF (XML version) file. When the PDF is downloaded, so is the associated FDF/XFDF file. You place form fields on the PDF (which it sounds like already exist). They fill that information in and (if you add a button to the PDF form) click on the button which basically does a POST back to the server with these fields.

At that point you can save them to a database, merge them with a PDF, etc.

BTW - the XFDF/FDF files aren't really necessary to just fill in a form. You would only need them if you want to be able to display a PDF that has form fields and to fill those form fields in automatically. If you are always displaying a blank PDF for them to fill in you can get away with just adding a button which posts back to the server.