Open
Description
I have a SVG containing a pattern and a rect which is filled with said pattern:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="200" height="200">
<defs>
<pattern x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse" id="SvgjsPattern1003">
<rect width="10" height="10" fill="purple" x="0" y="0"></rect>
<rect width="10" height="10" fill="pink" x="10" y="10"></rect>
</pattern>
</defs>
<rect width="75" height="75" fill="url('#SvgjsPattern1003')"></rect>
</svg>
When I convert to PDF with a x and/or y offset then the pattern doesn't inherit the offset. It doesn't start at (0, 0) of the SVG inside the PDF but apparently the pattern starts at (0, 0) of the PDF.
const pdfDoc = new jsPDF({ orientation: 'l', unit: 'pt', format: 'a4' })
pdfDoc.svg(nested.node, {
x: 17,
y: 32,
})
.then(() => {
pdfDoc.save('testStuffPDF')
})
And when I print the PDF then the printer adds some margins of its own which offsets the pattern again so that the printed element filled with the pattern doesn't look the same as its counterpart on the screen.
I know that the pattern inside a SVG always starts at (0, 0) of the SVG itself.
This is the behavior I would also expect to be seen in the PDF. Pattern should start at the origin of the SVG inside the PDF not the origin of the PDF.