I can reproduce the problem also with this code, where only a single field is flattened:

        PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
        List<PDField> list = new ArrayList<>();
        list.add(acroForm.getField("VN_NAME"));
        acroForm.flatten(list, true);

All annotations gone. Yeah, this seems to be a bug.

Tilman

Am 26.06.2021 um 04:44 schrieb Tilman Hausherr:
I don't have Acrobat 5 but I did find a problem using the code you suggested:

ALL page widget annotations are gone, instead of only those that were flattened. For example VP_TELEFON_FREIW is not readonly and it is still in the field list but missing from the page.

The OK file does not bring this problem.

The "bad" file brings this log message, I wonder if this is related.

"There has been a widget with a missing page reference, will check all page annotations"

Tilman

Am 25.06.2021 um 08:25 schrieb Ranjeet Kuruvilla:

Please try this

PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
List<PDField> list = new ArrayList<>();
for (PDField field : acroForm.getFieldTree())
{

if(field.isReadOnly())

{

    list.add(field);

}

}

acroForm.flatten(list, true);

and then open the PDF via Acrobat 5. You will see in SourceFailure.pdf, that the fields, that were Readonly are still there.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to