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()