0

I need help:

I have the same problem as here: How to fill XFA form using iText?

"This document enabled extended features. This document was changed since it was created and using extended features isn't possible anymore."

I do not know how to use PdfStamper. Here is my code. Can you pls tell me how to use PdfStamper in my code.

Output PDF document is now read-only (I am not able to write in Fields), will PdfStamper also solve the read-only problem?

string DEST = "C:\\PDF\\code_empty1.pdf";
string SRC = "C:\\PDF\\code_empty.pdf";
string XML = "C:\\PDF\\code_emptyKopie.xml";


ManipulatePdfFill(DEST);

void ManipulatePdfFill(string dest)

{
    PdfDocument pdfdoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
    PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfdoc, true);

    XfaForm xfa = form.GetXfaForm();

    // Method fills this object with XFA data under datasets/data.
    xfa.FillXfaForm(new FileStream(XML, FileMode.Open, FileAccess.Read));
    xfa.Write(pdfdoc);

    pdfdoc.Close();
}
kHLVT
  • 93
  • 6
user1862965
  • 327
  • 3
  • 15
  • 1
    Hi, can you attach the PDF/XML files that you are using to run your code? – Alexey Subach Apr 27 '22 at 08:46
  • `PdfStamper` is a class used in iText 5 and earlier. Its functionality is a special case of the `PdfDocument` class in iText 7 when generated with both a `PdfReader` and a `PdfWriter` argument. The _append mode_ mentioned in that `PdfStamper` answer can be set by using an additional `StampingProperties` constructor argument with `useAppendMode` selected. Nonetheless, Adobe Acrobat is very picky and attempts to recognize and reject changes by other software. – mkl May 01 '22 at 14:25
  • I am not able to attach PDF (sensible data is in PDF) – user1862965 May 05 '22 at 08:28

0 Answers0