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
| PageNumber | One-based page number that receives the /AF binding; an out-of-range value rejects the call |
|---|---|
| Source | Binary bytes to embed; must not be empty |
| DisplayName | Title registered in the EmbeddedFiles name tree; must not be empty and must not duplicate an existing embedded-file title |
| MIMEType | MIME type stored in the file specification; must not be empty |
| Description | Optional description written to the file specification /Desc entry; may be empty |
| Relationship | Relationship role, one of Source, Data, Alternative, Supplement or Unspecified |
Return values
| 0 | Validation failed: no document, empty source or display name, duplicate embedded-file title, invalid relationship, or a PDF/A mode that forbids arbitrary attachments |
|---|---|
| Ref | Handle 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");