d3.js - Convert dc.js chart to pdf -
i using dc.js create charts. want export charts pdf. seems converting svg , using perl scripts convert svg pdf way. suggestions?
i've used method using inkscape (on server):
js:
// --- create chart before --- postdata = { 'url':cryptojs.md5(window.location.href).tostring(), //used name file based on url (used caching, containing parameters in case) 'svg':$('#chart').html() //the created svg chart (using jquery here) }; $.post('create_pdf.php',postdata); //post svg php (using jquery here)
create_pdf.php:
//save svg file xyz.svg file_put_contents($_post['url'] . '.svg',$_post['svg']); // run command: inkscape -z xyz.svg -a xyz.pdf // png do: inkscape -z xyz.svg -e xyz.png $com = 'inkscape -z ' . $_post['url'] . '.svg -a ' . $_post['url'] . '.pdf'; exec($com);
note: use d3.js directly, not dc.js (not sure that)
Comments
Post a Comment