Flatten Annotations in Java

When flattening an annotation, the annotation is removed from a document, but its visual representation is kept intact. A flattened annotation is still visible but is no longer editable by your users or by your app. This can be used, for example, to permanently apply annotations to your document or to make annotations visible to viewers that otherwise can’t show annotations (like Safari on iOS). If not specified, an export will keep all annotations as they are.

To flatten annotations when saving, there’s an option in the DocumentSaveOptions class:

document.save(new DocumentSaveOptions.Builder().flattenAnnotations(true).build());

Note that if you set flattenAnnotations to true in DocumentSaveOptions, the incrementalSave property is ignored because flattening requires a full rewrite of the PDF.