API referenceCore SDK

pdfLoadSVG

The SVG parser-instance API: load an SVG once, inspect

C
SI32 __stdcall pdfLoadSVGA(PPDF IPDF, const char* FileName);
SI32 __stdcall pdfLoadSVGW(PPDF IPDF, const wchar_t* FileName);
SI32 __stdcall pdfLoadSVGFromBuffer(PPDF IPDF, void* Buffer, UI32 BufSize);
BOOL32 __stdcall pdfGetSVGSize(PPDF IPDF, SI32 Handle, double* Width, double* Height);
SI32 __stdcall pdfGetSVGSymbolCount(PPDF IPDF, SI32 Handle);
SI32 __stdcall pdfGetSVGSymbolNameA(PPDF IPDF, SI32 Handle, SI32 Index, char* Buffer, UI32 BufSize);
BOOL32 __stdcall pdfDeleteSVG(PPDF IPDF, SI32 Handle);
Delphi
function pdfLoadSVGA(const IPDF: PPDF; const FileName: PAnsiChar): Integer; stdcall;
function pdfLoadSVGW(const IPDF: PPDF; const FileName: PWideChar): Integer; stdcall;
function pdfLoadSVGFromBuffer(const IPDF: PPDF; const Buffer: Pointer; BufSize: Cardinal): Integer; stdcall;
function pdfGetSVGSize(const IPDF: PPDF; Handle: Integer; Width, Height: PDouble): LongBool; stdcall;
function pdfGetSVGSymbolCount(const IPDF: PPDF; Handle: Integer): Integer; stdcall;
function pdfGetSVGSymbolNameA(const IPDF: PPDF; Handle, Index: Integer; Buffer: PAnsiChar; BufSize: Cardinal): Integer; stdcall;
function pdfDeleteSVG(const IPDF: PPDF; Handle: Integer): LongBool; stdcall;

Purpose. The SVG parser-instance API: load an SVG once, inspect it, and place it any number of times, instead of re-parsing the file on every pdfInsertSVG call.

Description. pdfLoadSVGA/W parse an SVG file — and pdfLoadSVGFromBuffer an in-memory SVG image — into a document-owned parser instance and return a 1-based handle; each call creates a NEW instance, so the same file can be loaded twice and yield two independent handles. A missing file or unparseable image answers -1. pdfGetSVGSize reports the intrinsic size from the SVG's viewBox/width/height. pdfGetSVGSymbolCount and pdfGetSVGSymbolNameA enumerate the image's named symbol elements (the name call fills Buffer and returns the name length, so a two-call size-then-fetch pattern works). pdfDeleteSVG releases one instance; every instance is released with the document in any case.

Parameters.

ParameterDescription
IPDFDocument handle.
FileName / Buffer+BufSizeThe SVG source, as a path or as bytes in memory.
HandleParser-instance handle from a load call.
Index0-based symbol index for the name query.
Width, HeightReceive the intrinsic size.

Return value. Load calls: a handle >= 1, or -1 on failure. pdfGetSVGSize/pdfDeleteSVG: True/False. pdfGetSVGSymbolCount: the symbol count. pdfGetSVGSymbolNameA: the name length, -1 for a bad handle or index.

See also. pdfInsertSVG (one-shot parse and place).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfLoadSVGW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string FileName);
public static extern int pdfLoadSVGA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string FileName);
Area
Core SDK
Category

Core

Exported names

pdfLoadSVGW pdfLoadSVGA

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.