SVG to PDF conversion

SVG to PDF conversion is available starting with XFINIUM.PDF 5.3.

A SVG file is loaded in a PdfSvgDrawing object and then displayed on the PDF page using DrawFormXObject method (PdfSvgDrawing class inherits from PdfFormXObject).

SVG to PDF - Tiger
The well known tiger SVG image is converted to PDF like this:

After the SVG file is loaded in the PdfSvgDrawing object you can initiate explicitly the conversion by calling the PdfSvgDrawing.RenderSvgDrawing method. This method causes the parsing of the SVG file and now the SVG image size can be read from the PdfSvgDrawing.Width and PdfSvgDrawing.Height properties. The SVG drawing still needs to be drawn on the page using DrawFormXObject method.

By default the conversion process uses Helvetica family of fonts for text. If you want to use another font for drawing text you can set the DefaultRegularFont, DefaultBoldFont, DefaultItalicFont and DefaultBoldItalic properties of the PdfSvgDrawing class.

Leave a Reply