| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
DynaPDF.InsertSVG
Places a SVG graphic on the currently open page, template, or pattern.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| DynaPDF | 16.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "DynaPDF.InsertSVG"; PDF; PosX; PosY; Width; Height { ; SymbolID; Flags } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| The PDF reference returned from DynaPDF.New. | |||
| PosX | Destination x-coordinate | ||
| PosY | Destination y-coordinate | ||
| Width | Destination width | ||
| Height | Destination height | ||
| SymbolID | Encoded symbol name | Optional | |
| Flags | The flags. Currently none available. |
Optional |
Result
Returns OK or error.
Description
Places a SVG graphic on the currently open page, template, or pattern.As described at DynaPDF.LoadSVG, a symbol name is might be required in order to load the desired symbol or graphic.
This is a native SVG-to-PDF converter that translates SVG graphics directly into PDF drawing operations and resources. Vector graphics remain vector-based whenever possible, preserving their scalability and rendering quality.
The converter supports commonly used SVG features including paths and basic shapes, transformations, clipping, text, gradients, patterns, reusable elements, symbols, nested SVG documents, viewports and view boxes, as well as a subset of CSS relevant to SVG rendering.
SVG files containing multiple embedded SVG graphics can be enumerated and individual graphics can be selected by their symbol id. This makes it possible to efficiently process SVG icon and symbol collections without extracting the individual SVG documents beforehand.
The converter includes protection against cyclic and recursive references and is designed to handle malformed or unsupported SVG constructs gracefully.
DynaPDF implements the SVG features required for a broad range of real-world SVG documents but full conformance with every feature of the SVG and CSS specifications is not provided. SVG Graphics are drawn into a clipping path so that contents outside the bounding box of the graphic remains invisible.
Positioning & Scaling
If top down coordinates are active (see DynaPDF.SetPageCoords for further information), PosX / PosY is the upper left corner of the graphic. If bottom up coordinates are active, PosX / PosY is the lower left corner of the graphic.
The width and height can be calculated as follows:
- If Width and Height is 0 the function uses the original width or height from the svg file.
- If Width or Height is 0, the missing value is calculated in relation to the given value of Height or Width to preserve the aspect ratio. The resulting output is a vector graphic with exact proportions relative to its original size.
- If Width or Height is negative, the graphic is scaled to the absolute value and mirrored on the x- or y-axis.
See also InsertSVG function in DynaPDF manual.
Examples
Draw a SVG:
# Start new PDF document
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
Set Variable [ $r ; Value: MBS("DynaPDF.AppendPage"; $pdf) ]
#
# Load SVG
Set Variable [ $r ; Value: MBS("DynaPDF.LoadSVG"; $pdf; SVG::SVG) ]
#
# Place the image
Set Variable [ $width ; Value: 500 ]
Set Variable [ $Height ; Value: 0 // automatic ]
Set Variable [ $r ; Value: MBS("DynaPDF.InsertSVG"; $pdf; 0; 0; $width; $height) ]
#
# close page and save
Set Variable [ $r ; Value: MBS("DynaPDF.EndPage"; $pdf) ]
Set Field [ MyTable::ContainerField; MBS( "DynaPDF.Save"; $pdf; "report.pdf" ) ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
Set Variable [ $r ; Value: MBS("DynaPDF.AppendPage"; $pdf) ]
#
# Load SVG
Set Variable [ $r ; Value: MBS("DynaPDF.LoadSVG"; $pdf; SVG::SVG) ]
#
# Place the image
Set Variable [ $width ; Value: 500 ]
Set Variable [ $Height ; Value: 0 // automatic ]
Set Variable [ $r ; Value: MBS("DynaPDF.InsertSVG"; $pdf; 0; 0; $width; $height) ]
#
# close page and save
Set Variable [ $r ; Value: MBS("DynaPDF.EndPage"; $pdf) ]
Set Field [ MyTable::ContainerField; MBS( "DynaPDF.Save"; $pdf; "report.pdf" ) ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]
See also
- DynaPDF.AppendPage
- DynaPDF.EndPage
- DynaPDF.GetSVGSymbolCount
- DynaPDF.InsertImage
- DynaPDF.LoadSVG
- DynaPDF.LoadSVGFile
- DynaPDF.New
- DynaPDF.Release
- DynaPDF.Save
- DynaPDF.SetPageCoords
Release notes
- Version 16.4
- Added DynaPDF.LoadSVG, DynaPDF.LoadSVGFile and DynaPDF.InsertSVG functions.
Blog Entries
This function checks for a license.
Created 8th August 2026, last changed 25th August 2026
MarkDown version: DynaPDFInsertSVG.md