You must be logged in to post your query.
Home › Forums › Chart Support › Export to pdf not working
Tagged: C#, PDF Export, PDF rendering
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
@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.
___ Suyash Singh Team CanvasJS
i tried the same code but after generating pdf it shows only x and y axis not shows the coloured bar
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.
yes i was animating it .now the data is print but half graph is print on it not full
my problem is solve Thank you for your help
my chart is also getting cut while exporting to pdf. Any possible solutions?
@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
try using Zetpdf. it is .net SDK for adding PDF render and print support in .net applications and best for every developer needs.
You must be logged in to reply to this topic. Login/Register