We're having a problem filling in forms produced by some versions of
LiveCycle Designer; while the code works with 8.2, 9.0 results in missing
PDF Producer & other header values. So we extracted a page from one of the
newer and were relieved to see it render properly. However, Adobe Acrobat
doesn't recognize any forms, but even if you cancel from the offer to find
fields for you, it will display them; Adobe Reader doesn't prompt to save
the form as it used to and LiveCycle can't convert with a message for each
field: Unable to import field 'untitled Unable to read the 'name' property
for the field
'form1[0].Page1-SectionA[0].A0310[0].A0310FField[0].A0310FField[0]'.'
because: .
The extract code
PdfReader reader = new PdfReader(@"V:\Fredda\sample.pdf");
Document document = new
Document(reader.GetPageSizeWithRotation(1));
PdfCopy copy = new PdfCopy(document, new
FileStream(@"V:\Fredda\sample2.pdf", FileMode.Create));
document.Open();
copy.AddPage(copy.GetImportedPage(reader, 1));
document.Close();
The fill in form code
string pdfTemplate = @"V:\Fredda\sample2.pdf";
string newFile = @"V:\Fredda\fredda2_filled.pdf";
PdfReader pdfReader = new PdfReader(pdfTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new
FileStream(
newFile, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
pdfFormFields.SetField("resident[0]", "hi kids");
// report by reading values from completed PDF
string sTmp = "Completed fields";
MessageBox.Show(sTmp, "Finished");
// flatten the form to remove editting options, set it to false
// to leave the form open to subsequent manual edits
pdfStamper.FormFlattening = false;
// close the pdf
pdfStamper.Close();
And pdfReader.AcroFields.Fields is empty. Thank you in advance for any
assistance.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/