PDFium Delphi Component Docs

AddAnnotationFileAttachment method

Component: TPdf  ·  Unit: PDFium
Attach an embedded file to an existing annotation and fill in its contents in one call

Syntax

function AddAnnotationFileAttachment(AnnotIndex: Integer; const Name: WString; const FileData: TBytes): Boolean;

AnnotIndexInteger. Zero-based index of the annotation on the current page, typically one of subtype anFileAttachment
NameWString. File name recorded for the attachment, as a viewer would show it
FileDataTBytes. Bytes of the embedded file. An empty array creates the attachment entry with no contents
ResultBoolean. True when both the attachment and its contents were written

Description

Attaches a file to one annotation, which is what a FileAttachment annotation shows as its paperclip or pushpin marker. Document-level attachments are separate and go through CreateAttachment

On success the page is marked as modified, so a subsequent SaveAs carries the attachment into the file

A False result means nothing was attached: either the annotation could not be opened or the PDFium build does not export annotation attachments

See Also

CreateAttachment, Attachment, CreateAnnotation, AttachmentName