I created a PDF with Master PDF Editor containing one form text field.
When manipulating that PDF file with iText7-Community
I manage to find that field and to set its value. However, when I flatten the output PDF file that field is ripped and just disappears.
Bottom line: field shows up fine without flattening and disappears when flattening.
I ran isXfaPresent()
from XfaForm
and the response was false
, so I understand it is indeed AcroForm
.
So, this is what I tried:
PdfReader reader = new PdfReader("path-to-file.pdf");
PdfWriter writer = new PdfWriter("path-to-dest-file.pdf");
PdfDocument doc = new PdfDocument(reader, writer);
PdfAcroForm form = PdfAcroForm.getAcroForm(doc, false);
form.getField("treinamento").setValue(param);
System.out.println("----> " + form.getField("treinamento").value);
form.flattenFields();
doc.close();
System.out
shows the value correctly setup but the output file doesn't show it. If I comment form.flattenFields()
it does.
Any help on what I should do to fix this is greatly appreciated.