Code:
using (FileStream pdf = new FileStream("C:/test.pdf", FileMode.Open))
using (FileStream xml = new FileStream("C:/test.xml", FileMode.Open))
using (FileStream filledPdf = new FileStream("C:/test_f.pdf", FileMode.Create))
{
PdfReader.unethicalreading = true;
PdfReader pdfReader = new PdfReader(pdf);
PdfStamper stamper = new PdfStamper(pdfReader, filledPdf);
stamper.AcroFields.Xfa.FillXfaForm(xml);
stamper.Close();
pdfReader.Close();
}
This code throws no exception and everything seems to be ok, but if I open filled pdf, Adobe Reader says something like that:
This document enabled extended features. This document was changed since it was created and using extended features isn't possible anymore.
Some fields are filled properly, but I can't edit it. Some fields are empty. If I choose xml manually by clicking 'Import data' from Adobe Reader, form is filled properly, so I guess there is no error in xml.