API reference › PDF/A & Conformance
pdfAddSVGAnnotationFromFile
Embed an SVG file (rendered directly to the page) or a SWF
int32_t __stdcall pdfAddSVGAnnotationFromFileA(PPDF IPDF, double Left, double Top, double Width, double Height, const char* FileName, int32_t Options);
int32_t __stdcall pdfAddSWFAnnotationFromFileA(PPDF IPDF, double Left, double Top, double Width, double Height, const char* FileName, const char* Title, int32_t Options);
function pdfAddSVGAnnotationFromFileA(const IPDF: PPDF; Left, Top, Width, Height: Double; FileName: PAnsiChar; Options: Integer): Integer; stdcall;
function pdfAddSWFAnnotationFromFileA(const IPDF: PPDF; Left, Top, Width, Height: Double; FileName, Title: PAnsiChar; Options: Integer): Integer; stdcall;
Purpose. Embed an SVG file (rendered directly to the page) or a SWF (Flash) file (attached as an embedded file behind a /Screen annotation) at a given rectangle.
Description. Architecturally important: pdfAddSVGAnnotationFromFile does not create a self-rendering annotation — it draws the SVG content directly into the current page's content stream at load time (DrawSVG), and *separately* registers a Square annotation with an invisible border (/BS /W 0) and the literal placeholder text "SVG" as /Contents — the annotation exists as a marker/anchor (e.g. for later hit-testing or metadata), not as the thing that actually displays the SVG; the visible rendering is baked into the page itself and would persist even if the marker annotation were later deleted. pdfAddSWFAnnotationFromFile is a real, standard-conforming multimedia embed: attaches the SWF bytes as a document embedded file (AttachFileBuf) and registers a /Screen-subtype annotation carrying the title — actually playing the SWF at view time is the responsibility of the viewer/reader's own multimedia handler, not this SDK, per the normal PDF /Screen annotation contract. Both wrappers accept Options but neither passes it through to the real creation methods — it has no observable effect.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Left, Top, Width, Height | Placement rectangle on the current page. |
FileName | Path to the SVG/SWF file. |
Title | *(SWF only)* Used as both the embedded file's name fallback (if non-empty) and the annotation's /T. |
Options | Accepted but never used by either function. |
Return value. The new annotation's handle; 0 if the file doesn't exist/is empty, or no page is currently open.
C# (P/Invoke)
public static extern int pdfAddSVGAnnotationFromFileW(IntPtr IPDF, double Left, double Top, double Width, double Height, IntPtr FileName, int Options);
public static extern int pdfAddSVGAnnotationFromFile(IntPtr IPDF, double Left, double Top, double Width, double Height, IntPtr FileName, int Options);
public static extern int pdfAddSVGAnnotationFromFileA(IntPtr IPDF, double Left, double Top, double Width, double Height, IntPtr FileName, int Options);
Content Creation
pdfAddSVGAnnotationFromFileW
pdfAddSVGAnnotationFromFile
pdfAddSVGAnnotationFromFileA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.