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

I have no idea about this issue belong to svg2pdf or jsPdf? #61

Closed christee closed 5 years ago

christee commented 5 years ago

It‘s not support chinese ?

doc.addFont('msyh.ttf', 'msyh', 'normal');
doc.setFont('msyh');

Pdf exported by using doc.text is ok,

doc.text(20, 20, '导出标题');

but used svg2pdf is not working, chinese became messy code.

svg2pdf(element, doc, {
         xOffset: 0,
         yOffset: 0,
         scale: 0.6
});

like this

SÑNºTX

Is there any way to fix this ?

yGuy commented 5 years ago

Please provide a short, complete example. Why would you believe that the font should be used for the SVG element?

christee commented 5 years ago

So, that's my confused place, i don't understand the font can applied on SVG element or not. Code that wrote follow the docs is simple, now i don't have it. I am care about how to convert encoding with the content of SVG element.

yGuy commented 5 years ago

Did you see this: https://github.com/yWorks/svg2pdf.js/blob/master/tests/custom-fonts.html ?

christee commented 5 years ago

Thanks, I will try this later !

christee commented 5 years ago

Yeah, this issue has been solved ! So appreciated for your help!