2

I am working in an application that creates PDFs for new hires (direct deposit,emergency contact etc.). I used Adobe Livecycle Designer to add and tag fields on the PDFs and then I set the value of the fields with ItextSharp/vb.net. For example: pdfFormFields.SetField("lastName", employee.lastName). This has worked fine since 2013. Now I have to update the PDfs with new versions and I am using the newer version of Designer that ships with AEM. Now when my application creates a PDF I get this message:

The document you are trying to load requires Adobe Reader 8 or higher. You may not have the Adobe Reader installed or your viewing environment may not be properly configured to use Adobe Reader. For information on how to install Adobe Reader and configure your viewing environment please see http://www.adobe.com/go/pdf_forms_configure.

This happens even if I take a working PDF , open it in Designer and save it without changing anything. All existing PDFs in the application display correctly/as expected.

I did install the latest version of ItextSharp to see if that would fix it.Same error. I notice that on the working PDFs XFA/AcroShort2LongName has a count, whereas on my bad PDFs the count is 0. Also on the bad PDFs something called TemplateSom does list all of my form fields.

Any assistance would be greatly appreciated, I have been scouring the internet for 12 hours and have found nothing similar or even close to helpful.

Code:

 Dim outDirectory As String = Server.MapPath("Files\\")
 Dim temploc As String= "Templates\\" + FormName.Trim
 Dim pdfTemplate As String = HttpContext.Current.Server.MapPath(temploc)
 Dim newFile As String = outDirectory + FormName.Trim
 Dim pdfReader As New PdfReader(pdfTemplate)
 Dim pdfStamper As New PdfStamper(pdfReader, New FileStream( _
   newFile, FileMode.Create))
 Dim pdfFormFields As AcroFields = pdfStamper.AcroFields
  pdfFormFields.SetField("empFirst", firstname)
  pdfFormFields.SetField("empLast", lastname)
  pdfFormFields.SetField("empMiddle", middlename)
  pdfStamper.FormFlattening = True
  pdfStamper.Close()
Tim S. Van Haren
  • 8,861
  • 2
  • 30
  • 34
  • iTextSharp isn't a PDF viewer, so it never renders PDFs. Can you show us some code, so that we get an idea of what you're trying to do? Also: can you provide the PDF you create with AEM? – Bruno Lowagie Oct 21 '15 at 23:18
  • Sorry perhaps render was the wrong word to use. We create the file and then display it in a web browser. I will post some of the code etc. Thanks! – Iknowsomethings Oct 21 '15 at 23:43
  • I am not sure how to provide the PDF. Longtime reader, first time actually asking a question. – Iknowsomethings Oct 21 '15 at 23:54
  • 1
    You are using code that allows you to fill out a form that is created using AcroForm technology, but you are using a designer that creates forms that are based on the XML Forms Architecture (XFA). That explains why you don't succeed in filling out the form. The fields `empFirst`, `empLast` and `empMiddle` don't exist in your form. The form expects that you inject XML into it. – Bruno Lowagie Oct 21 '15 at 23:58
  • Thanks Bruno, but my forms that were tagged in Designer ES2 work just fine with this code.. It is only the new ones that I am creating in AEM that do not work. – Iknowsomethings Oct 22 '15 at 00:00
  • 1
    Designer ES2 was able to create hybrid forms. Those are forms that are defined twice: once as an AcroForm, once as an XFA form. iText filled out the AcroForm and practically ignored the XFA. Now you probably only have an XFA form. As long as you don't share the form, it's hard to tell. Of course: since you've been using iText for so long, you are (or should be) a customer of iText Software. You can always mail support at iText Software to share your form. – Bruno Lowagie Oct 22 '15 at 00:03
  • I'd be happy to share the pdf with you, just not sure how to do that. Thanks for clarifying my issue , much appreciated. – Iknowsomethings Oct 22 '15 at 00:13
  • Share the file using some third party file sharing mechanism (Dropbox, Google drive) and post the url here. – mkl Oct 22 '15 at 04:45

0 Answers0