API referenceAnnotations

pdfDeleteAnnotation

Remove an annotation — either everywhere in the document

C
BOOL32 __stdcall pdfDeleteAnnotation(PPDF IPDF, uint32_t Handle);
BOOL32 __stdcall pdfDeleteAnnotationFromPage(PPDF IPDF, uint32_t PageNum, uint32_t Handle);
Delphi
function pdfDeleteAnnotation(const IPDF: PPDF; Handle: Cardinal): LongBool; stdcall;
function pdfDeleteAnnotationFromPage(const IPDF: PPDF; PageNum, Handle: Cardinal): LongBool; stdcall;

Purpose. Remove an annotation — either everywhere in the document (pdfDeleteAnnotation) or from one specific page only (pdfDeleteAnnotationFromPage), leaving its handle registration intact.

Description. pdfDeleteAnnotation removes the annotation object from every page's CreatedAnnots list it appears on, then removes its entry from FAnnotByHandle entirely — after this call, Handle no longer resolves through any lookup in this SDK. pdfDeleteAnnotationFromPage removes it from only the specified PageNum's list — it does not touch FAnnotByHandle: Handle remains fully resolvable via pdfGetAnnot/pdfGetAnnotType/pdfGetAnnotBBox etc. even though it no longer appears on that page's own index-based enumeration (pdfGetPageAnnot) — this is the real mechanism behind the divergence between pdfGetAnnotCount and FAnnotByHandle.Count noted above. Because an annotation is (in normal usage) only ever placed on one page, pdfDeleteAnnotationFromPage on that page effectively creates an orphaned, page-less-but-still-handle-resolvable annotation, rather than deleting it in the sense a caller might expect.

Parameters.

ParameterDescription
IPDFDocument handle.
HandleDocument-wide annotation handle.
PageNum*(FromPage only)* 1-based page number to remove the annotation from.

Return value. True if Handle (and, for FromPage, PageNum) resolved and the removal occurred; False otherwise.

Remarks. To fully remove an annotation (both from its page and from handle resolvability), use pdfDeleteAnnotation, not pdfDeleteAnnotationFromPage.

C# (P/Invoke)

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

Core

Exported names

pdfDeleteAnnotation

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.