Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.FlattenAnnots

Flatten annotations.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.FlattenAnnots"; PDF; Flags )   More

Parameters

Parameter Description Example
PDF The PDF reference returned from DynaPDF.New. $pdf
Flags The flags as text or number.
Default is None.
Can be None, UseViewState, MarkupAnnots or both combined as VisibleMarkupAnnots.
"UseViewState"

Result

Returns number or error message.

Description

Flatten annotations.
Draws all annotations according to the used flags on the corresponding pages and deletes the annotations when finish. The flatten flags can be combined. The flag MarkupAnnots causes that non-markup annotations will be left intact (all kind of link, sound, and file attach annotations).

The function flattens only annotations which contain an appearance stream. The function does not create missing appearances on demand.

If the function succeeds the return value is the number of annotations which are still in memory.

By default all annotations which have an appearance stream and which have the print flag set are flattened. All annotations are deleted when the function returns with the exception of file attachment annotations. If you want to flatten the view state then set the flag affUseViewState.

Flag NameFlag NumberDescription
None0Printable annotations independent of type.
UseViewState1If set, annotations which are visible in a viewer become flattened.
MarkupAnnots2If set, markup annotations are flattened only. Link, Sound, or FileAttach annotations are no markup annotations. Such types will be left intact.
NonPDFA_14If set, flatten all annotations which are not supported in PDF/A 1.
NonPDFA_28If set, flatten all annotations which are not supported in PDF/A 2 or 3.
FormFields16If set, form fields will be flattened too.
UseFieldViewState32Meaningful only if affFormFields or affSigFields is set. If set, flatten the view state of form fields. Use the print state otherwise.
SigFields64Meaningful only if affFormFields is not set. If set, signature fields with an appearance stream will be flattened.
KeepLinkAnnots4096If set, link annotations will be kept.
KeepFileAttach8192If set, file attachment annotations will be kept.
KeepTextAnnots16384If set, text annotations will be kept.
KeepEmptySigFields32768If set, signature fields which are not already signed will be kept.
PreserveZOrder4194304If set, preserve the z-order under any circumstances. That means visible overlapping annotations or form fields will be flattened, regardless the type.

See also FlattenAnnots function in DynaPDF manual.

Examples

Flatten annotations and form fields:

# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
    Perform Script [ Specified: From list ; “InitDynaPDF” ; Parameter: ]
End If
#
# New PDF environemnt
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
# Load PDF from container
Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; MyTable::Input PDF) ]
Set Variable [ $r ; Value: MBS("DynaPDF.ImportPDFFile"; $pdf; 1) ]
# Flatten annotations
Set Variable [ $r ; Value: MBS( "DynaPDF.FlattenAnnots"; $PDF ) ]
# and the form fields
Set Variable [ $r ; Value: MBS( "DynaPDF.FlattenForm"; $PDF ) ]
# Save
Set Field [ MyTable::Output PDF ; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]

See also

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 18th June 2022


DynaPDF.FlattenAnnotOrField - DynaPDF.FlattenForm