Visual Studio 2008
Adobe Acrobat Reader v10.0.1
I have written a small piece of code to open an existing PDF that has some fields in it using iTextSharp, fill in the fields, flatten the file to remove the field placeholders and then save it to a file.
The problem I have is when closing the file after viewing it in Acrobat Reader I am prompted with "Do you want to save changes to 'Test.pdf' before closing?"
If I view the template file it closes without any prompting so I know the problem didn't pre-exist.
If I omit the part in the code about flattening the form then it closes successfully without the prompting but the form fields are still visible in the document when you view it. This is what has led me to believe that it has something to do with iTextSharps FormFlattening that is causing the problem.
I think the prompt is because Acrobat Reader has fixed something that iTextSharp has screwed up and is prompting to save a fixed copy of the document.
Any ideas how I can fix this?
' read the template document
Dim r as New PdfReader("C:\Template.pdf")
' Create a FileStream to the output PDF document
Dim FS as New IO.FileStream("C:\Test.pdf", IO.FileMode.Create)
Dim ps as New PdfStamper(r, FS)
' Retrieve the properties of PDF form with AcroFields object
Dim af As AcroFields = ps.AcroFields
' Fill in the fields
' Make resultant PDF Read-Only for end user
ps.FormFlattening = True
ps = Nothing