From ee93c70867c8203584719d0ab88525ec41664bba Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 22 Sep 2022 00:35:37 +0200 Subject: [PATCH] Fix 'translate' in SvgToPdf --- Utils/svgToPdf.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Utils/svgToPdf.ts b/Utils/svgToPdf.ts index 91b10df04..4172d8ebb 100644 --- a/Utils/svgToPdf.ts +++ b/Utils/svgToPdf.ts @@ -67,12 +67,21 @@ class SvgToPdfInternals { if (t === null) { return null; } - const scaleMatch = t.match(/scale\(([-0-9.]*)\)/) + const scaleMatch = t.match(/scale\(([-0-9.]+)\)/) if (scaleMatch !== null) { const s = Number(scaleMatch[1]) return SvgToPdfInternals.dummyDoc.Matrix(1 / s, 0, 0, 1 / s, 0, 0); } + const translateMatch = t.match(/translate\(([-0-9.]+), ?([-0-9.]*)\)/) + if (translateMatch !== null) { + const dx = Number(translateMatch[1]) + const dy = Number(translateMatch[2]) + console.log("Translating", dx, dy) + return SvgToPdfInternals.dummyDoc.Matrix(1, 0, 0, 1, dx, dy); + } + + const transformMatch = t.match(/matrix\(([-0-9.]*),([-0-9.]*),([-0-9.]*),([-0-9.]*),([-0-9.]*),([-0-9.]*)\)/) if (transformMatch !== null) { const vals = [1, 0, 0, 1, 0, 0] @@ -449,6 +458,9 @@ class SvgToPdfInternals { } public handleElement(element: SVGSVGElement | Element): void { + if(element.id === "path15616"){ + console.log("Handling element", element) + } const isTransformed = this.setTransform(element) try {