سؤال

In my search for a way to export my SVG to pdf I've come across jsPDF. My problem is when trying to create a filled path. Searching the git of jsPDF makes me believe I'm to use the SVGtoPDF plugin, but there is also a plugin named "sillysvgrenderer" which has the "addSVG" function.

I can't get the latter working, but then again I can't get the SVGtoPDF function to fill my path.

Can someone help me with this? Is there perhaps a better (but still free) solution to export my SVG to a pdf document (client-side)?

هل كانت مفيدة؟

المحلول

Solution: Using PhantomJS made me able to render my own SVG-code and save it as a .pdf file.

Javascript:

var svgString = "<svg xmlns='http://www.w3.org/2000/svg' version='1.1'><path d='M0,0L600,200L0,200z'></path></svg>";

var page = require('webpage').create();

page.content = svgString;

page.render('aRectangle.png');
phantom.exit();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top