API referenceAnnotations

pdfFlattenAnnots

Flatten every annotation in the document in one call

C
int32_t __stdcall pdfFlattenAnnots(PPDF IPDF, TAnnotFlattenFlags Flags);
Delphi
function pdfFlattenAnnots(const IPDF: PPDF; Flags: TAnnotFlattenFlags): Integer; stdcall;

Purpose. Flatten every annotation in the document in one call (form fields are not included — see pdfFlattenForm for those).

Description. Iterates every page's CreatedAnnots list, flattens each one, and clears the list — after this call, pdfGetAnnotCount/ pdfGetPageAnnotCount (Annotation Lifecycle and Enumeration) report 0 for every page. Same dropped-parameter finding as pdfFlattenAnnotOrField: Flags is accepted but never consulted — there is no way to selectively exclude certain annotation types or kinds from bulk flattening through this parameter despite its presence.

Parameters.

ParameterDescription
IPDFDocument handle.
FlagsAccepted but silently dropped — has no effect.

Return value. The number of annotations flattened; 0 if IPDF is invalid or none existed.

Remarks. This does not touch form fields (widget annotations backing interactive fields survive this call as fields, though their pure annotation-only counterparts — Text, Highlight, Line, etc — do not). Use pdfFlattenForm separately to flatten form fields.

See also. pdfFlattenAnnotOrField.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfFlattenAnnots(IntPtr IPDF, uint Flags);
Area
Annotations
Category

Core

Exported names

pdfFlattenAnnots

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.