Gynnad Gynnad - 3 years ago 183
iOS Question

iText PDF values not shown on iOS

We create PDF files with iText (in Java) which are working fine on Windows / Android, however when we open such file on an iPhone the acroFields that were set in the code are empty.

We are using the following code and the setGenerateAppearances is already set to true.

PdfStamper pdfStamper = new PdfStamper(templateReader, pagePdf);
AcroFields acroFields = pdfStamper.getAcroFields();
acroFields.setGenerateAppearances(true);
acroFields.setField("creationdate", creationDate);


Any idea why this isn't working on the iPhone but it does work on all other devices?

Thanks

Answer Source

As stated by Bruno Lowagie, the issue can be resolved by using the flatten option, which should be set before the pdfStamper.close() has been called:

// flatten the PDF (so the values are visible when PDF is downloaded on iOS / OS X)
pdfStamper.setFormFlattening(true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download