save the chart in PDF usinig Jspdf
@jerairrest Hi I need to save the chart in PDf file using JsPDF like the example below using JsPDF and chartJS Example:- https://fiddle.jshell.net/kL68ey5z/94/
so I need the steps or the solution to extract the chart in PDF( as the image) .
@DocX @octalmage @mosanger @nrdobie @soska @ Hi Guys Anyone can help me
I need the same solution.
No clue. This is just a wrapper for ChartJS, so I would check with them!
https://fiddle.jshell.net/kL68ey5z/105/
Thanks @octalmage .
Closing
Solution link is broken, can someone post the solution to this issue?
Solution link is still broken. Could someone post the solution again? Would appreciate that 👍
+1 i also need this solution
import PdfConverter from 'jspdf';
import DomToImage from 'dom-to-image';
const convertToPdf = () => {
const canvas= document.querySelector('.canvas')[0];
const imgWidth = 190;
const pdf = new PdfConverter('p', 'mm');
DomToImage.toPng(canvas).then(dataURL => {
const imgHeight = (canvas.clientHeight * imgWidth) / canvas.clientWidth;
pdf.addImage(dataURL, 'PNG', 10, 20, imgWidth, imgHeight);
});
pdf.save('save.pdf');
};