Skip to main content
Skip table of contents

Support for a symbol element in SVG

The release of iText Core 7.1.13 includes a number of bug fixes as well as useful feature additions.
As we continue to work on increasing support for SVG the support for another SVG element - <symbol> is among those features. This support is applicable to both the iText 7 Core library and version 3.0.2 of the pdfHTML add-on

a <symbol> element is used to define graphical template objects which can be instantiated by a <use> element.
If you'd like to know more about this element please check the specification https://developer.mozilla.org/en-US/docs/Web/SVG/Element/symbol.


From now on you can convert any SVG containing <symbol> e.g:


CODE
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg"
	 xmlns:xlink="http://www.w3.org/1999/xlink">
	<symbol id="myDot" viewBox="0 0 500 500" >
		<circle cx="5" cy="60" r="50" stroke-width="20" stroke="#f00" style="fill: skyblue;"/>
	</symbol>
	<use xlink:href="#myDot" x="0"  y="100" style="fill: yellow;"/>
	<use xlink:href="#myDot" x="250" y="100" style="fill: purple;"/>
</svg>

to PDF

bothStyleAttrTest.pdf

using iText Core and without any additional coding.
Code remains the same: 

JAVA

JAVA
SvgConverter.createPdf(svg,pdfOutputStream,writerprops);


C#

C#
SvgConverter.CreatePdf(svg,pdfOutputStream,writerprops);


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.