PDFium Delphi Component Docs

GetAnnotationDictionaryValue method

Component: TPdf  ·  Unit: PDFium
Reads one key directly from the dictionary of an annotation on the current page and reports its value kind together with the decoded scalar

Syntax

function GetAnnotationDictionaryValue(AnnotIndex: Integer; const Key: WString): TPdfDictionaryValue;

AnnotIndexInteger. Zero-based index of the annotation on the current page, in the range 0 .. AnnotationCount - 1. An out-of-range index raises an EPdfError
KeyWString. Name of the dictionary entry to read, UTF-8 encoded before the native call
ResultTPdfDictionaryValue. Kind carries the native value type; string, name and number values are decoded into StringValue / NumberValue with HasScalarValue = True

Description

Every annotation is backed by a PDF dictionary, and the component's record model maps only the common entries. This call reaches into the raw dictionary and reads a single key, so application-defined entries (a review status, a grouping id, a vendor extension) become visible without walking the object graph

The value kind is queried natively and decoded into a TPdfDictionaryValueKind: pdvkUnknown, pdvkBoolean, pdvkNumber, pdvkString, pdvkName, pdvkArray, pdvkDictionary, pdvkStream, pdvkNull or pdvkReference. Only the scalar kinds are fetched: strings and names are decoded into StringValue, numbers into NumberValue (read at single precision by the native API), and HasScalarValue marks a successful fetch. Values without a scalar payload — booleans, arrays, nested dictionaries, streams — are reported by Kind alone

For keys the record model already exposes, prefer Annotation: it normalises and validates the common fields. Reach for this call only when a key sits outside the model

Remarks

Example

var
  Value: TPdfDictionaryValue;
begin
  // read a vendor-specific review status from annotation 2
  Value := Pdf1.GetAnnotationDictionaryValue(2, 'ReviewStatus');
  if (Value.Kind = pdvkName) and Value.HasScalarValue then
    Memo1.Lines.Add('Status: ' + Value.StringValue);
end;

See Also

Annotation, AnnotationCount, GetAttachmentDictionaryValue