AddFileAttachmentA

Document properties

Description

The trailing A denotes the ANSI (char) DLL entry point; the ActiveX/COM surface exposes only the Unicode form. Behaviour is identical to AddFileAttachment and string arguments are interpreted using the current SetAnsiMode code page

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 behavior: 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 DLAddFileAttachmentA(InstanceID: Integer; Title: PAnsiChar; EmbeddedFileID: Integer): Integer;

DLL

int DLAddFileAttachmentA(int InstanceID, const char * Title, int EmbeddedFileID);

Parameters

TitleThe attachment name shown in the viewer and used as the key in the /EmbeddedFiles name tree. It must not be blank.
EmbeddedFileIDThe value returned by AddEmbeddedFile.

Return values

0The EmbeddedFileID is invalid, the title is blank, or no document is active.
1The 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