API referenceAnnotations

pdfFlattenAnnotOrField

Flatten a single annotation or form field, addressed by a

C
BOOL32 __stdcall pdfFlattenAnnotOrField(PPDF IPDF, uint32_t Index, TAnnotFlattenFlags Flags);
Delphi
function pdfFlattenAnnotOrField(const IPDF: PPDF; Index: Cardinal; Flags: TAnnotFlattenFlags): LongBool; stdcall;

Purpose. Flatten a single annotation or form field, addressed by a combined document-wide sequential index — a fourth distinct indexing scheme in this volume, different from both the document-wide Handle space (FAnnotByHandle, Annotation Lifecycle and Enumeration) and the per-page Index space (pdfGetPageAnnot, Annotation Lifecycle and Enumeration).

Description. **Verified: Index counts sequentially across every page's annotations *and* form fields combined, in page order, annotations before fields on each page — the internal walk increments one counter k first over Page.CreatedAnnots then over Page.FormFields, for each page in turn, and flattens whichever object k lands on when it equals Index. This is not the same numbering as any other index/handle space used elsewhere in this volume (or in V09 Forms' own field enumeration) — a caller must independently walk annotations-then-fields per page in document order to compute the right Index for a specific target, or simply flatten via pdfFlattenAnnots (below) for the common "flatten everything" case instead. Flags (TAnnotFlattenFlags) is accepted by the ABI but never passed through** to the underlying FlattenByIndex — whatever selective/behavioral flags the type suggests (e.g. preserve read-only fields, or flatten one kind but not another) have no effect; flattening always applies the same fixed logic regardless of Flags.

Flattening itself (FlattenOneAnnot/FlattenOneField) bakes the target's current appearance into the page's content stream and removes it from the page's interactive-object list (CreatedAnnots/FormFields) — the object no longer exists as an annotation/field afterward; only its rendered appearance remains, indistinguishable from ordinary page content.

Parameters.

ParameterDescription
IPDFDocument handle.
IndexCombined document-wide 0-based index across every page's annotations-then-fields, in page order.
FlagsAccepted but silently dropped — has no effect regardless of value.

Return value. True if Index resolved to an existing annotation or field and it was flattened; False if Index is out of range or IPDF is invalid.

See also. pdfFlattenAnnots, pdfFlattenForm (the analogous whole-document form-field flattener, not covered in this chapter).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Annotations
Category

Core

Exported names

pdfFlattenAnnotOrField

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.