Home Forums Chart Support Export to pdf not working

Export to pdf not working

Viewing 9 posts - 1 through 9 (of 9 total)
  • #15556

    i embeded export to pdf function on my code
    when i was click on it it was working but when i open that file it not show graph only it shows x and y axis content and when i print it it shows only half graph

    #15557

    @priya,

    We don’t have exporting chart as pdf as an inbuilt feature as of now. However with couple of lines of code you can export chart as pdf using jsPDF. Please find the code-snippet below.

    var pdf = new jsPDF();
    pdf.addImage(dataURL, 'JPEG', 0, 0);
    pdf.save("download.pdf");

    Please take a look at this JSFiddle for complete code.
    exporting chart as pdf using jspdf

    ___
    Suyash Singh
    Team CanvasJS

    #15558

    i tried the same code but after generating pdf it shows only x and y axis not shows the coloured bar

    #15559

    @priya,

    You may be encountering that the datapoints are not visible but axis is visible if you have enabled animation. This happens because when animation is enabled, you may be exporting the chart even when it’s still animating. Exporting chart after the animation gets completed should work fine in such cases. You can add some delay before exporting the chart to resolve this. Please take a look at this updated JSFiddle for working code.

    ___
    Suyash Singh
    Team CanvasJS

    #15566

    yes i was animating it .now the data is print but half graph is print on it not full

    #15567

    my problem is solve
    Thank you for your help

    #20883

    my chart is also getting cut while exporting to pdf. Any possible solutions?

    #20893

    @theprogrammers,

    You can pass image width and height parameters to addImage method of jsPDF to handle clipping of chart while exporting it as PDF. Please refer to jsPDF documentation for more information on the same. Below is the code-snippet with width & height parameters.

    var dataURL = canvas.toDataURL();
    var pdf = new jsPDF();
    pdf.addImage(dataURL, 'JPEG', 20, 20, 170, 80); //addImage(image, format, x-coordinate, y-coordinate, width, height)
    pdf.save("download.pdf");

    Please take a look at this updated JSFiddle for complete code.


    Vishwas R
    Team CanvasJS

    #25773

    try using Zetpdf. it is .net SDK for adding PDF render and print support in .net applications and best for every developer needs.

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

You must be logged in to reply to this topic.