With iText 7.1.14 and pdfHTML 3.0.3, we are pleased to announce that we have added full support for SVG’s <pattern> element. This element is used to define a graphics object which can be "tiled" fixed intervals in x and y to cover an area.

With full support for the <pattern> element in iText 7 Core’s SVG module, it is now possible for iText 7 Core’s SVG module as well as the pdfHTML add-on to correctly render <pattern> elements in SVG files and HTML-embedded SVG respectively.

You can consult the w3 website link: https://www.w3.org/TR/SVG11/pservers.html for more information about the SVG <pattern> element.

Example input SVG:
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
   <defs>
       <pattern id="star" x="2" y="2" width="14" height="14"
       patternContentUnits = "userSpaceOnUse" patternUnits="userSpaceOnUse">
           <rect fill="none" stroke-width="0.4" stroke="orange" x="0" y="0" width="14" height="14"/>
           <rect fill="none" stroke-width="0.4" stroke="blue" x="0" y="0" width="10" height="10"/>
           <polygon stroke="none" fill="red" points="0,0 2,5 0,10 5,8 10,10 8,5 10,0 5,2"/>
       </pattern>
   </defs>
   <rect x="0" y="0" width="100" height="100" fill="url(#star)" stroke-width="0.8" stroke="black"/>
</svg>

The iText 7 Core code for generating the PDF from SVG remains the same:

Example input HTML:

<!DOCTYPE html>
<html>
<body>
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
   <defs>
       <pattern id="star" x="2" y="2" width="14" height="14"
                patternContentUnits="userSpaceOnUse"
                patternUnits="userSpaceOnUse">
           <rect fill="none" stroke-width="0.4" stroke="orange" x="0" y="0" width="14" height="14"/>
           <rect fill="none" stroke-width="0.4" stroke="blue" x="0" y="0" width="10" height="10"/>
           <polygon stroke="none" fill="red" points="0,0 2,5 0,10 5,8 10,10 8,5 10,0 5,2"/>
       </pattern>
   </defs>
   <rect x="0" y="0" width="100" height="100" fill="url(#star)" stroke-width="0.8" stroke="black"/>
</svg>
</body>
</html>

The pdfHTML code for generating the PDF from HTML remains the same: