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
654 stars 101 forks source link

Support for width and height instead of scale #79

Closed GuiRitter closed 5 years ago

GuiRitter commented 5 years ago

Hi everyone.

Is your feature request related to a problem? Please describe. I'm having a very hard time to find out which scale I have to use for my SVG elements to appear on the PDF with the right size.

Describe the solution you'd like I'd rather have the option to input which width and height I want the SVG to have when added to the PDF.

Describe alternatives you've considered A way to find out what is the resulting size of added elements would help a lot towards figuring out the scale.

Additional context I can't think of anything else I could've added.

Thanks in advance.

HackbrettXXX commented 5 years ago

Figuring out the scale is pretty easy:

const svgWidth = ...
const desiredWidth = ...
const scale = desiredWidth / svgWidth

So we won't add this to the API.

GuiRitter commented 5 years ago

Yes, it is, but that's not related to my problem. I just found out that I had a bug in my code that was making me believe that the scale was not consistent.

Sorry for taking you time, but I wouldn't have looked at my code from another perspective if I hadn't opened this issue. I've been frying my brain for days looking in the wrong place...

Thanks either way.