dompdf / php-svg-lib

SVG file parsing / rendering library
GNU Lesser General Public License v3.0
1.4k stars 77 forks source link

Matrix transform not working on SVG #65

Open raduvarga opened 3 years ago

raduvarga commented 3 years ago

I am trying to generate a PDF with dompdf which includes a SVG that has a matrix transform at its top level. The SVG renders correctly in the browser, in the PDF however the matrix transform is not being applied.

In one specific example, the matrix transform "matrix(-1, 0, 0, 1, 0, 0)" is doing a flip on the x axis, however if I replace the matrix with a "scaleX(-1)" transform, this does get applied correctly in the PDF. Inside the SVG, there are many other matrix transforms that are being respected, so it seems that just the top level one is not working. I have also tried to wrap the SVG with a div that contains that matrix transform, with no success.

Thoughts?

raduvarga commented 3 years ago

Correction for the above: The "scaleX(-1)" fix only works if I apply it too the "style" of the parent "img" element where the SVG is being shown, it doesn't work on the top level of the SVG itself, nor does it work on the "transform" property of both "img" or "svg".