pdfFileAttachAnnot
Create a FileAttachment ("paperclip") annotation, either
int32_t __stdcall pdfFileAttachAnnotA(PPDF IPDF, double PosX, double PosY, TFileAttachIcon Icon, const char* Author, const char* Desc, const char* AFile, BOOL32 Compress);
int32_t __stdcall pdfFileAttachAnnotExA(PPDF IPDF, double PosX, double PosY, TFileAttachIcon Icon, const char* FileName, const char* Author, const char* Desc, void* Buffer, uint32_t BufSize, BOOL32 Compress);
function pdfFileAttachAnnotA(const IPDF: PPDF; PosX, PosY: Double; Icon: TFileAttachIcon; const Author, Desc, AFile: PAnsiChar; Compress: LongBool): Integer; stdcall;
function pdfFileAttachAnnotExA(const IPDF: PPDF; PosX, PosY: Double; Icon: TFileAttachIcon; const FileName, Author, Desc: PAnsiChar; Buffer: Pointer; BufSize: Cardinal; Compress: LongBool): Integer; stdcall;
Purpose. Create a FileAttachment ("paperclip") annotation, either reading the attached file from disk (pdfFileAttachAnnot) or embedding an in-memory buffer under a given display filename (pdfFileAttachAnnotEx).
Description. Compress is accepted by the ABI on both variants but never passed to AddFileAttachAnnotH — silently dropped, no compression-toggle effect regardless of value (the embedded-file stream's actual compression, if any, is governed elsewhere by the document's general compression settings — pdfSetCompressionFilter/pdfSetCompressionLevel — not by this per-call flag).
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
PosX, PosY | Icon placement (no width/height — file-attachment icons render at a fixed standard size). |
Icon | Standard paperclip/graph/pushpin/tag icon. |
Author, Desc | /T, /Contents (description). |
AFile | *(plain)* Path to the file to embed (read from disk). |
FileName, Buffer, BufSize | *(Ex)* Display filename and in-memory bytes to embed. |
Compress | Accepted but silently dropped — has no effect. |
Return value. The new annotation's handle; 0 on failure (invalid IPDF, or — for the plain form — a source file read failure implied by downstream I/O, not independently re-verified as a distinct failure path in this chapter beyond the IPDF check).
C# (P/Invoke)
public static extern int pdfFileAttachAnnotA(IntPtr IPDF, double PosX, double PosY, TFileAttachIcon Icon, [MarshalAs(UnmanagedType.LPStr)] string Author, [MarshalAs(UnmanagedType.LPStr)] string Desc, [MarshalAs(UnmanagedType.LPStr)] string AFile, [MarshalAs(UnmanagedType.Bool)] bool Compress);
public static extern int pdfFileAttachAnnotW(IntPtr IPDF, double PosX, double PosY, TFileAttachIcon Icon, [MarshalAs(UnmanagedType.LPWStr)] string Author, [MarshalAs(UnmanagedType.LPWStr)] string Desc, [MarshalAs(UnmanagedType.LPWStr)] string AFile, [MarshalAs(UnmanagedType.Bool)] bool Compress);
Core
pdfFileAttachAnnotA
pdfFileAttachAnnotW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.