DrawSVGEx
Vector graphics, SVG, filter import
Description
Draw SVG with explicit filter rejection and diagnostics
Syntax
Delphi
Function TPDFlib.DrawSVGEx(Left, Top, Width, Height: Double; Const SVG, AltText: WideString; Options: Integer): Integer;DLL
int DLDrawSVGEx(int InstanceID, double Left, double Top, double Width, double Height, const wchar_t* SVG, const wchar_t* AltText, int Options);
int DLDrawSVGExA(int InstanceID, double Left, double Top, double Width, double Height, const char* SVG, const char* AltText, int Options);ActiveX
Function PDFlib::DrawSVGEx(Left As Double, Top As Double, Width As Double, Height As Double, SVG As String, AltText As String, Options As Long) As LongParameters
| Left | X coordinate of the placement origin in current page user space |
|---|---|
| Top | Y coordinate of the placement origin in current page user space |
| Width | Placement width in user space units; it must be positive and finite |
| Height | Placement height in user space units; it must be positive and finite |
| SVG | SVG document markup including the root element; an empty value is rejected |
| AltText | Accessible description used for tagging; an empty value omits it |
| Options | 0 imports tolerantly; PDF_SVG_IMPORT_STRICT_FILTERS (1) rejects unsupported filter operations, invalid parameters, unavailable filter rasterization and exceeded budgets; add PDF_SVG_IMPORT_ALLOW_FILTER_IMAGE_FILES (2) to let feImage elements read bounded local image files; other bits are rejected |
Return values
| 1 | Supported content was committed to the page |
|---|---|
| 0 | The import was rejected or produced no output; LastErrorCode is 540 and GetLastSVGImportDiagnostics holds the findings |
Remarks
Uses the geometry, placement and accessible-description parameters of DrawSVG and returns 1 when supported content is committed, or 0 on rejection or empty output
Set Options to 0 for permissive filter import or PDF_SVG_IMPORT_STRICT_FILTERS (1) to reject unsupported filter operations, invalid parameters, unavailable filter rasterization and exceeded budgets; combine it with PDF_SVG_IMPORT_ALLOW_FILTER_IMAGE_FILES (2) to let image elements and filter images read bounded local image files; other option bits are rejected
The filter profile includes normal, multiply, screen, darken and lighten blending, continuous primitive subregions, fractional offsets, region-aware convolution sampling and tiling of referenced subregions; inspect GetSVGFilterCapabilitiesJSON for coordinate syntax and finite limits
A rejected call sets LastErrorCode to 540 and leaves existing page content, selected font and automatic-tag structure unchanged; resources allocated during an unsuccessful attempt can remain unused in the document
Permissive mode records findings and uses a primitive input or the captured unfiltered source when a filter cannot be applied; inspect GetLastSVGImportDiagnostics after every call
Strict mode qualifies the implemented filter subset, not arbitrary SVG geometry, typography, CSS, external assets or accessibility; it does not certify complete SVG fidelity
The new options and reports are exposed through native Delphi, Windows DLL, macOS Dylib and ActiveX IPDFlibrary16; existing ActiveX DrawSVG calls remain permissive
ActiveX exposes this method through IPDFlibrary16 and the default dispatch interface; Pascal Automation callers can use CoPDFlibrary.CreateConversionTools
The macOS Dylib exposes the same wide and A C entry points shown above using the C calling convention; string pointers belong to the instance and must be copied before the next string-returning call, and A variants follow the configured ANSI or UTF-8 mode
An inline image that occurs several times in one drawing is embedded once, but every call embeds its own copy, so a drawing placed on many pages stores its images once per call; call DeduplicateResources before saving to merge the identical copies
Bounded diffuse and specular lighting
feDiffuseLighting and feSpecularLighting use the input alpha as a height map and accept exactly one distant, point or spot light; positions, surface heights and sampling distances use the primitive coordinate system
Surface normals use the SVG boundary-aware Sobel kernels, including corners and edges; a single-pixel axis contributes zero slope, diffuse output is opaque and specular alpha is the maximum of its computed premultiplied RGB channels
lighting-color defaults to white without automatic inheritance, supports currentColor and explicit inherit, and is converted into the selected filter working color space; a parsed color alpha component does not scale illumination
Positive kernelUnitLength values establish a bounded implicit sampling grid; the input is bilinearly reconstructed on that grid, Sobel lighting is evaluated there and the result is reconstructed at the original resolution, with a partial final sampling cell retaining its rectangle coverage
Point lights use the local surface height without distance attenuation, and coincident point/surface samples contribute zero illumination; spot lights support direction, focus and a limiting cone with four-point coverage sampling, while undefined spot directions are diagnosed
Specular exponents range from 1 through 128, nonnegative lighting constants and spot exponents are bounded to 1000000, coordinates to 1073741824 and kernel spacing to at least 1e-12; the implicit grid remains limited to 2048 pixels per dimension and consumes the shared buffer and work budgets
Missing or multiple lights, unsupported children, animation, invalid colors, invalid sampling and exhausted budgets produce findings with strict page-output rollback; finite grid reconstruction and four-point cone coverage remain approximations, and fullFidelity stays false
Deterministic turbulence
feTurbulence supports turbulence and fractalNoise, one or two nonnegative baseFrequency values, truncated signed seeds, octave accumulation and stitch or noStitch tile behavior in the primitive coordinate system
The seeded gradient sequence and interpolation follow the SVG 1.1 algorithm; four independent channels are generated in the selected filter working color space, then RGB is premultiplied by the generated alpha before entering the pipeline
Stitching adjusts base frequencies using relative frequency change and applies the specified octave lattice wrapping against the original primitive subregion, including when the stored result is cropped; it does not redefine the function as a globally periodic sampler outside that subregion
The bounded profile accepts 0 through 12 octaves, baseFrequency values through 1000000 and seed magnitudes through 9007199254740991; scaled lattice coordinates at every octave are limited to 1073741824, with numeric underflow, nonfinite values and undefined zero-length seeded gradients diagnosed
Zero octaves or zero frequencies produce transparent turbulence and straight RGBA channels of 0.5 for fractalNoise; shared work is reserved before output allocation, so larger images or octave counts can reach the work limit before the maximum dimension limit
Bounded filter image resources
feImage accepts local SVG graphic fragments and base64 PNG or JPEG data URIs; href takes precedence over xlink:href, and standalone raster images use preserveAspectRatio with xMidYMid meet by default, none for stretching and slice for clipped filling
Local graphic fragments use referenced graphic content without moving or changing the source DOM; symbol references require a qualified viewBox, use graphs are bounded and cycles, executable or animated fragments and unsupported target types are diagnosed
Local image files require the explicit DrawSVGEx option PDF_SVG_IMPORT_ALLOW_FILTER_IMAGE_FILES (2), independently of strict filter rejection (1); the option is reapplied on every call, including cached SVG documents, and network URLs, UNC paths, device paths and external SVG documents are unsupported
The file is read once with a byte limit, and the approved bytes are passed to the decoder without a second filename read; nested image nodes inside referenced graphics follow the same policy, and ordinary image nodes outside feImage need the same option before a local file is read: without it only inline data URIs are drawn, and with it a plain path or file URL on a local drive is accepted while UNC, device and network references are still left out
PNG preflight checks chunk extents, CRC, dimensions, transparency layout and exact bounded scanline expansion, including Adam7 passes; JPEG preflight checks baseline or progressive 8-bit frame structure, quantization and Huffman tables, scan headers and exact container termination, with final rendering delegated to the native codec
Encoded data is limited to 16 MiB per resource and 64 MiB per conversion, decoded scanline or component data to 64 MiB per conversion, dimensions to 8192 and total pixels to 4194304; PNG ICC expansion is limited to 4 MiB, container segments to 10000 and JPEG scans to 64
Active image references are limited to 32 levels, use graphs to 64 levels and 100000 visited nodes; source decoding and temporary storage also consume the shared filter work and 512 MiB buffer reservation
The native private SVG rasterizer preserves source alpha and uses bilinear image sampling with edge extension to prevent a transparent border from reducing the opacity of a scaled image; vector fragments still use the native finite-resolution renderer, and fullFidelity remains false
Continuous filter domains and sampling
Each primitive result has a continuous domain and a bounded local raster grid; referenced inputs are resampled in premultiplied working color space, and coincident domains and grids preserve exact samples
The final result is mapped to the filter output using rectangle overlap coverage and premultiplied bilinear sampling; repeated identity operations do not multiply the same fractional boundary coverage again
Named results retain both stored domains and original subregion bounds, so tiling preserves fractional origins and periods and leaves samples outside stored input transparent; offset and convolution distances use the same local-grid coordinate model
Blur remains a three-box approximation and morphology uses local integer radii; bilinear finite-grid resampling is a bounded reconstruction model rather than a claim of resolution-independent analytic equivalence, and fullFidelity remains false
Local filter inheritance
Filters may reference another filter in the same SVG fragment with href or xlink:href; nearer attributes override referenced attributes, and the nearest filter with its own filter primitives supplies the complete primitive list
Resolution uses a private attribute view and leaves the source DOM and primitive ownership unchanged; inherited raster settings and working color space remain effective across repeated rendering
References are local fragments only and do not load files or network resources; missing or non-filter targets, cycles, more than 32 chain nodes, more than 128 children or attributes per chain node, attribute values above 65536 UTF-16 units and references above 4096 UTF-16 units are diagnosed, with strict mode rejecting the import atomically