10

I want display a PDF as an html page - where the user will be allowed to enter the fillable data. My problem is not how to import/fill data (I was able to do it using FDF/XML and ITextSharp). My only concern is how to show it to the user so that he/she can see the form, fill/edit data, and should be done with it.

I tried saving the PDF as an image file, and showing it as an background-image - but it was very crude! - Iam hoping that there should be some elegant solution.

Thanks for you help!

Sekhar
  • 5,614
  • 9
  • 38
  • 44
  • Do you need some sort of PDF-to-HTML solution? Otherwise is it allowable for your users to open a plugin or external application like Adobe Reader? – Massimog Dec 03 '10 at 10:06

5 Answers5

3

PDF already has form-filling capabilities. Just display the PDF and let the user fill it in. You can add the fields using Adobe Acrobat. The form can be submitted back to your server like a Web page or just e-mailed.

kindall
  • 178,883
  • 35
  • 278
  • 309
  • 3
    How would you submit the form back to your server @kindall? I've just did a lot of research on this domain, and it feels like there's no good js solution to grab the pdf and post it back to server. Which leads me to my next question - How would you 'show' the pdf in the browser in order to make it fillable? pdf.js from Mozzila cannot render form fields, while the other js libraries are not much better. The only option is to embed the pdf as an iframe, object or using a embed tag. – qgicup Apr 20 '15 at 10:23
  • Can the fields from the pdf be extracted when the form is submitted? – Pratik Khadloya Dec 25 '15 at 03:10
  • I tried this kind of thing myself and it didn't really seem possible, and if it's possible, it's definitely not abundantly clear how it's done. It would be nice to see some kind of example. – Jason Swett Jul 21 '16 at 20:56
2

If you're using ASP.NET, you might consider this commercial PDF viewer option (which renders the PDF as HTML for you, preserving form fields)

userx
  • 3,769
  • 1
  • 23
  • 33
2

Here is what I used to populate a PDF form using HTML and PHP a while back. It worked great for me. http://koivi.com/fill-pdf-form-fields/tutorial.php (Working link: http://web.archive.org/web/20170315111519/http://koivi.com/fill-pdf-form-fields/)

You can always use a PDF generator to actually render a PDF with the data you submit from an HTML form. Here is an example of a class that does that http://www.fpdf.org/

Hope this works for you.

Mukesh Chapagain
  • 25,063
  • 15
  • 119
  • 120
serialk
  • 926
  • 7
  • 11
0

A different solution could be using flyingsoucer to generate the pdf from your html.

http://today.java.net/pub/a/today/2007/06/26/generating-pdfs-with-flying-saucer-and-itext.html

Uberto
  • 2,712
  • 3
  • 25
  • 27
-2

PDF is pretty much a write-only format, unless you want to render it. I strongly recommend changing your requirements.

Mark Storer
  • 15,672
  • 3
  • 42
  • 80