API referencePDF/A & Conformance

pdfAddBookmarkEx

Three ABI generations of the same bookmark-creation

C
int32_t __stdcall pdfAddBookmarkA(PPDF IPDF, const char* Title, int32_t Parent, uint32_t DestPage, int32_t Open);
int32_t __stdcall pdfAddBookmarkExA(PPDF IPDF, const char* Title, int32_t Parent, uint32_t NamedDest, BOOL32 Open);
int32_t __stdcall pdfAddBookmarkEx2A(PPDF IPDF, const char* Title, int32_t Parent, void* NamedDest, BOOL32 Unicode, BOOL32 Open);
Delphi
function pdfAddBookmarkA(const IPDF: PPDF; const Title: PAnsiChar; Parent: Integer; DestPage: Cardinal; Open: Integer): Integer; stdcall;
function pdfAddBookmarkExA(const IPDF: PPDF; const Title: PAnsiChar; Parent: Integer; NamedDest: Cardinal; Open: LongBool): Integer; stdcall;
function pdfAddBookmarkEx2A(const IPDF: PPDF; const Title: PAnsiChar; Parent: Integer; const NamedDest: Pointer; Unicode, Open: LongBool): Integer; stdcall;

Purpose. Three ABI generations of the same bookmark-creation function, all funneling into one real AddBookmark(Title, ParentH, Dest, Open) method — differing in how the destination is addressed.

Description. pdfAddBookmark takes a raw 1-based page number as destination. pdfAddBookmarkEx takes a named-destination handle instead. **Ignored parameter: pdfAddBookmarkEx2's NamedDest (void*) is never read at all** — the wrapper body always passes the literal 0 to AddBookmark regardless of what NamedDest points to, so despite the richer-looking void*/Unicode signature suggesting a by-name or typed destination lookup, pdfAddBookmarkEx2 can never actually target any destination — every bookmark it creates ends up with Dest = 0. pdfAddBookmarkA's ANSI Title is converted to wide via a raw per-byte cast (WideChar(Ord(Title[I-1]))), not a real codepage-aware MultiByteToWideChar conversion — correct only for the Latin-1/low-256 range, the same class of lossy ANSI-widening documented elsewhere in this SDK (e.g. the reverse-direction pdfFindBookmarkA truncation, Named Destinations, Page Labels, Geospatial Measure, and Viewports).

Parameters.

ParameterDescription
IPDFDocument handle.
TitleBookmark text; A variant widened byte-for-byte (Latin-1 only, not full codepage-aware).
ParentParent bookmark handle (0/negative = top level).
DestPage*(plain form)* 1-based destination page.
NamedDest*(Ex)* Named-destination handle (Cardinal) — genuinely used. *(Ex2)* void*accepted but never read; always resolves to Dest = 0.
Unicode*(Ex2 only)* Accepted; moot given NamedDest is unused.
OpenWhether the bookmark starts expanded.

Return value. The new bookmark's handle; 0/negative on failure.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfAddBookmarkExA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Title, int Parent, uint NamedDest, [MarshalAs(UnmanagedType.Bool)] bool Open);
public static extern int pdfAddBookmarkExW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string Title, int Parent, uint NamedDest, [MarshalAs(UnmanagedType.Bool)] bool Open);
Area
PDF/A & Conformance
Category

Content Creation

Exported names

pdfAddBookmarkExA pdfAddBookmarkExW

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.