function GetAnnotationDictionaryValue(AnnotIndex: Integer; const Key: WString): TPdfDictionaryValue;
| AnnotIndex | Integer. Zero-based index of the annotation on the current page, in the range 0 .. AnnotationCount - 1. An out-of-range index raises an EPdfError |
| Key | WString. Name of the dictionary entry to read, UTF-8 encoded before the native call |
| Result | TPdfDictionaryValue. Kind carries the native value type; string, name and number values are decoded into StringValue / NumberValue with HasScalarValue = True |
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 having to walk 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
pdvkUnknown with HasScalarValue = False; that combination means “no value”T (the subtype) and t are different entries
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;