yWorks/svg2pdf.js

SVG is upscaled in the pdf-file

Franky-W opened this issue · 3 comments

Hi,
thank you for this awesome library!

I create with svgdotjs a svg-image.
The problem:
The svg wich is shown in the PDF-File is way to big. One PDF-Page holds approx. 1/4 of the svg-image.
What can I do? What do I wrong?

HTML
<svg id="drawing" style="width:210mm; height:297mm"/>

JS-draw funtion
const template = '<rect width="690.74792" height="519.3775" ...' // holds svg-data as string
const draw = SVG(document.querySelector('#drawing'))
draw.svg(template)

JS-pdf function
const doc = new jsPDF()
const element = document.getElementById('drawing')
doc.svg(element, ) .then(() => { doc.save('myPDF.pdf') })

yGuy commented

The svg function takes a second parameter (the one that you omitted in your last snippet) that lets you define the size of the svg in the PDF. Did you try that?
See width and height options here.

Hello yGuy,
thank you for your fast response.
Yes I did, but the result is the same.

Even the code from here https://codepen.io/cl10k/project/editor/ZOjgJg dosent work for me.

Edit: vue-File attached.
HelloWorld.txt

Found the solution.
Added width, height and viewbox to the svg tag.