Jspdf: Svg isn't drawn

Created on 19 Dec 2018  路  5Comments  路  Source: MrRio/jsPDF

Are you using the latest version of jsPDF?
1.4.1

Have you tried using jspdf.debug.js?
Yes

Steps to reproduce
https://jsbin.com/rayizodoxi/edit?html,js,output

What I saw
Blank page

What I expected
Drawn svg

Hi, i want to create pdf from svg. I have sample svg code

<svg height="500" version="1.1" width="500" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;">
 <desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Rapha毛l 2.1.0</desc>
 <defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></defs>
 <text x="50" y="50" text-anchor="middle" font="10px &quot;Arial&quot;" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font: 10px Arial;" stroke-width="0.1155822959137042" transform="matrix(8.6436,-0.3768,0.3768,8.6436,-311.9625,-338.3442)">
  <tspan dy="3.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">TEXT</tspan>
 </text>
</svg>
var doc = new jsPDF('l', 'px', 'a4');
var svg = '<svg height="500" version="1.1" width="500" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Rapha毛l 2.1.0</desc><defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></defs><text x="50" y="50" text-anchor="middle" font="10px &quot;Arial&quot;" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font: 10px Arial;" stroke-width="0.1155822959137042" transform="matrix(8.6436,-0.3768,0.3768,8.6436,-311.9625,-338.3442)"><tspan dy="3.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">TEXT</tspan></text></svg>';
doc.addSVG(svg, 0, 0, 500, 500);
doc.save('Test.pdf');

i use addSvg method for pdf create. But pdf export blank page.

Where am i doing wrong?

Thank You.

Most helpful comment

better do this

https://jsbin.com/yimelaruwo/1/edit?html,js,output

All 5 comments

better do this

https://jsbin.com/yimelaruwo/1/edit?html,js,output

i saw this way, but i think i stubborn. Because i have want found solution with addSvg.
I give up.

Thank you.

I can understand, but addSVG is really not a good choice. Should be considered as deprecated.

hmm .... no comments solve the problem that the addSvg function is broken. Please reopen this issue until it is fixed!

See the comment in #2541.

Was this page helpful?
0 / 5 - 0 ratings