yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
667 stars 104 forks source link

Rotation and correct positioning of text elements fails #6

Closed henrikskar closed 8 years ago

henrikskar commented 8 years ago

Hi there,

There seems to be an issue with rotation and positioning of text elements. Here's a fiddle to show my problem: jsfiddle If I comment out the following code in my local fork, the text element will render as I want. That will however break some of your code, I guess.

if (m[1] && m[2]) {
  var t1 = new _pdf.Matrix(1, 0, 0, 1, m[1], m[2]);
  var t2 = new _pdf.Matrix(1, 0, 0, 1, -m[1], -m[2]);
  resultMatrix = _pdf.matrixMult(t2, _pdf.matrixMult(resultMatrix, t1));
}

Can anything be done to solve my use case?

Best regards, Henrik Skar

HackbrettXXX commented 8 years ago

Hi,

this seems to be a bug, where the "x" and "y" attributes and the "transform" attribute are applied in the wrong order. I made a commit to fix this: https://github.com/yWorks/svg2pdf.js/commit/39062b00cf6530923c3ef6706768675c99489395

I hope this solves your problem.

Best regards, Lukas Holländer

henrikskar commented 8 years ago

YesWorks,

Thank you so much!

Best regards, Henrik Skar