AddFileAttachment
Document properties
Description
Registers an existing embedded file as a document-level attachment in the PDF viewer. Readers that expose the Attachments panel show the supplied title and open the referenced embedded file when the user selects it.
Call AddEmbeddedFile first to copy the file bytes into the document and obtain the EmbeddedFileID. AddFileAttachment then adds that file specification to the Catalog /Names /EmbeddedFiles name tree without duplicating the embedded bytes.
PDF version behaviour: AddEmbeddedFile emits embedded file stream and file specification dictionaries, which require PDF 1.3. Registering the file in the document-level /Names /EmbeddedFiles name tree requires PDF 1.4. If the current document version is lower and the save version is not locked, AddFileAttachment automatically raises the document to PDF 1.4 and records /EmbeddedFiles name tree in AutoBumpedFeatures. If the caller locks a lower save version, the compatibility gate rejects the save with LastErrorCode 602.
Syntax
Delphi
function TPDFlib.AddFileAttachment(const Title: WideString; EmbeddedFileID: Integer): Integer;ActiveX
Function PDFlib::AddFileAttachment(Title As String, EmbeddedFileID As Long) As LongDLL
int DLAddFileAttachment(int InstanceID, wchar_t * Title, int EmbeddedFileID);Parameters
| Title | The attachment name shown in the viewer and used as the key in the /EmbeddedFiles name tree. It must not be blank. |
|---|---|
| EmbeddedFileID | The value returned by AddEmbeddedFile. |
Return values
| 0 | The EmbeddedFileID is invalid, the title is blank, or no document is active. |
|---|---|
| 1 | The embedded file was registered as a document-level attachment. |
Remarks
This function creates a document-level attachment list entry. To place a clickable icon or hotspot on a page, use AddLinkToEmbeddedFile instead. To embed and register a file in one call, use EmbedFile.
See also
AddEmbeddedFile, AddLinkToEmbeddedFile, EmbedFile, SetEmbeddedFileAFRelationship, EmbeddedFileCount