I am generating PDF file using jsPDF library. Everything is okay, but at page my chart has white background ( on PDF - black ):
Chart from my webpage:
And from PDF:
my code for generating file:
var newCanvas = document.querySelector('#canvasChart');
var newCanvasImg = newCanvas.toDataURL("image/jpeg", 1.0);
var doc = new jsPDF('landscape');
doc.setFontSize(20);
doc.text(15, 15, "Super Cool Chart");
doc.addImage(newCanvasImg, 'JPEG', 10, 10, 280, 150 );
doc.save('new-canvas.pdf');
Do you have an idea how to solve this ? Thanks in advance,
Maybe later, but I solved using PNG image:
var newCanvasImg = newCanvas.toDataURL("image/png", 1.0);
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With