AddPageAssociatedFileFromString

Embedded files

Description

Binds an embedded file built from a string to one page's /AF array

Syntax

Delphi

Function AddPageAssociatedFileFromString(PageNumber: Integer; Const Source, DisplayName, MIMEType, Description, Relationship: WideString): Integer;

Parameters

PageNumberOne-based page number that receives the /AF binding; an out-of-range value rejects the call
SourceBinary bytes to embed; must not be empty
DisplayNameTitle registered in the EmbeddedFiles name tree; must not be empty and must not duplicate an existing embedded-file title
MIMETypeMIME type stored in the file specification; must not be empty
DescriptionOptional description written to the file specification /Desc entry; may be empty
RelationshipRelationship role, one of Source, Data, Alternative, Supplement or Unspecified

Return values

0Validation failed: no document, empty source or display name, duplicate embedded-file title, invalid relationship, or a PDF/A mode that forbids arbitrary attachments
RefHandle of the new file specification object

Remarks

The payload is stored exactly like AddAssociatedFileFromString and registered in the EmbeddedFiles name tree, but the /AF association is written into the page dictionary instead of the document catalog so the binding survives save and load round trips. Relationship must be one of Source, Data, Alternative, Supplement or Unspecified. Writing a page /AF array raises the document to PDF 2.0.

Example

PDF.AddPageAssociatedFileFromString(1, XML, "page-data.xml", "text/xml", "Page payload", "Source");

See also

AddAssociatedFileFromString, GetAssociatedFileCount