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

Width and height properties not working anymore #43

Closed fskpf closed 6 years ago

fskpf commented 6 years ago

The width and height properties don't seem work properly anymore. For example, take test2.html and change the code to

    var width = 100;
    var height = 300;
    var pdf = new jsPDF('l', 'pt', [width, height]);

The resulting pdf is much wider than high. The same issue can be observed in http://live.yworks.com/demos/view/pdfexport/index.html or https://www.yworks.com/yed-live/ when changing the export rectangle to be smaller than high.

This used to work in the past as far as I can remember.

HackbrettXXX commented 6 years ago

The reason for that is that jsPDF swaps the width and height properties when they don't match the landscape/portrait argument. Just insert something like:

var pdf = new jsPDF(width > height ? 'l' : 'p', 'pt', [width, height]);
fskpf commented 6 years ago

I see. Works as expected now, thank you.