Home Forums Chart Support Export CanvasJS to PDF

Export CanvasJS to PDF

Viewing 3 posts - 1 through 3 (of 3 total)
  • #37134

    Hi Team,

    I want to download the CanvasJS chart as a PDF. I used jsPDf as u referred in jsfiddle.

    But the problem is I have rendered the chart in a dark theme. But I want the chart in a light theme when I try to download. Is there any option to update the chart theme dynamically before the download start? I don’t want any change in the application, it should be in a dark theme. Just need a light theme on the PDF.

    Please give me a solution to export the chart in a light theme and maintain the dark theme on the web page.




    To export the chart in a pdf with a light theme, you can use chart.set() to change the theme to light1 or light2 right before fetching the base64 image of the chart as shown in the code-snippet below,

        var pdf = new jsPDF();
        var chartTheme = chart.get("theme");
        chart.set("theme", "light2");
        var canvas = $("#chartContainer .canvasjs-chart-canvas").get(0);
        var dataURL = canvas.toDataURL();
        chart.set("theme", chartTheme);
        pdf.addImage(dataURL, 'JPEG', 0, 0);

    Kindly take a look at this JSFiddle for an example on the same with complete code.

    export chart to pdf using jspdf and toDataURL


    Thank you so much for the prompt reply. I get the idea now.

    Awesome plugin and works very well!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.