2

I have a few PDFs from various customers/vendors. My goal is that I am building a web app where a potential customer fills out a single form of data and then can generate all of the PDF's to print and sign.

The PDF's have fields in them that in adobe reader you can click and type in the data. However, this is sensitive financial data, and the PDF won't let you save to your desktop. There is actually a warning in adobe reader when you open the pdf and it prevents you from saving a completed form. I don't care about this feature. My users can save it if they want to take the risk if it becomes opened up when I generate the completed pdf myself.

The problem is that I need to generate these pdfs with my data injected into them without altering the style. I want to avoid manually building them, but I will if I have to. How can I generate the exact PDF format they gave me with the data filled in?

Josh
  • 16,286
  • 25
  • 113
  • 158
  • Possible duplicate of https://stackoverflow.com/q/6339453/9758687 there you will find also other solutions – Coden Dec 19 '22 at 17:14

2 Answers2

5

You could have a look at iTextSharp and the PdfStamper class - it allows you to load up an existing PDF, 'stamp' data into the fields and then flatten out the PDF which can be sent to the user:

http://sourceforge.net/projects/itextsharp/

Note that iTextSharp is paid for for commerical products - but there may well be other open sources librarires that can do this.

Paddy
  • 33,309
  • 15
  • 79
  • 114
  • Thanks Paddy! I'll give it a look. Considering the importance of this pdf generation, I don't think they will have an issue buying a license. Free is better, but I'll tell them to pay for what works. – Josh Jul 21 '11 at 13:38
  • @Josh - we've been using it for a while. Slight learning curve, but it's fast and does exactly what we need. – Paddy Jul 21 '11 at 15:50
  • 1
    interesting read: [itextsharp-license](http://stackoverflow.com/questions/8517776/itextsharp-license) – Răzvan Flavius Panda Apr 16 '13 at 13:05
  • Note that the current itextsharp license ( AGPL ) requires you to publish your own source code. It's one of the worst possible licenses out there. http://itextpdf.com/pricing – NotMe Jan 21 '15 at 18:40
1

You may try Aspose.Pdf for .NET to achieve your goal. You can fill the form fields using this component. If you do not want to allow the users to edit this data once it is filled in the PDF, you may flatten the fields as well. This will not change the existing layout of your PDF. The API is very simple along with complete documentation and support.

Disclosure: I work as developer evangelist at Aspose.

Shahzad Latif
  • 1,408
  • 12
  • 29
  • I tried Aspose, but it blows up on the line `Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form("input.pdf", "output.pdf");` with a NullReferenceException. ITextSharp works. – Josh Jul 28 '11 at 16:31