I have tested many JavaScript libraries that convert SVG to PDF for my web project including the above-mentioned one, and experienced over and over the same thing that the pdf gets produced at only screen-resolution. Finally, I have made very good experience with css2pdf (http://www.cloudformatter.com/css2pdf). It uses a small JavaScript library called "XEPOnline javascript" to extract the content of the svg including all the css-styling on the client-side, and sends this information to a XEP rendering engine on amazon cloud for generating the pdf. The output pdf file is high-resolution, please check out my example fiddle where I export Plotly.js and C3.js svg charts to pdf: http://jsfiddle.net/3hs7cs4f/10/
Here is the corresponding code to the fiddle:
<link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" />
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="http://www.cloudformatter.com/Resources/Pages/CSS2Pdf/Scrip /xeponline.jqplugin.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js"></script>
<script>
function addnsandprint(){
$('#c3_chart').find('svg').attr('xmlns','http://www.w3.org/2000/svg');
xepOnline.Formatter.Format('c3_chart',{pageWidth:'11in', pageHeight:'8.5in',render:'download', srctype:'svg'});
}
</script>
<body>
<br><br>
<!-- Source and on-click event for plotly.js -->
<div id="plotly_chart" style="width: 90%; height: 270px"></div>
<button onclick="return xepOnline.Formatter.Format('plotly_chart',{pageWidth:'11in', pageHeight:'8.5in',render:'download', srctype:'svg'});">Get plotly_PDF</button>
<!-- Source and on-click event for c3.js-->
<div id="c3_chart" style="width: 90%; height: 270px"></div>
<button onclick="return addnsandprint()">Get c3_PDF</button>
<!-- JAVASCRIPT for plotly.js chart -->
<script type="text/javascript">
Chart = document.getElementById('plotly_chart');
Plotly.plot( Chart, [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16] }], {
margin: { t: 0 } } );
</script>
<!-- JAVASCRIPT for j3.js chart -->
<script type="text/javascript">
var chart = c3.generate({
bindto: '#c3_chart',
padding: {
top: 10,
right: 70,
bottom: 50,
left: 75,
},
data: {
columns: [
['data1', 100, 200, 150, 300, 200],
['data2', 400, 500, 250, 700, 300],
]
}});
</script>
I would like to thank Kevin Brown (https://stackoverflow.com/users/2491227/kevin-brown) for his great help on getting everything running, please also have a look at my previous post SVG to PDF conversion working for Plotly.js but not for C3.js