Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit PDFs in Javascript?

Tags:

javascript

pdf

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.

like image 663
Fletcher Moore Avatar asked May 10 '10 14:05

Fletcher Moore


1 Answers

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.

like image 81
Paul Mrozowski Avatar answered Sep 27 '22 21:09

Paul Mrozowski