How to export report as PDF/CSV in ChartNew.js

0๐Ÿ‘

โœ…

I am not sure how to export chart report to PDF and CSV format with
ChartNew.js?

Since youโ€™ve put CSV, I presume you mean the data and not the chart.

For CSV, you can easily generate the file based on https://www.rfc-editor.org/rfc/rfc4180 with mostly string concatenation and wrapping. You could also do the same thing on the client side using Data URIs (see How to create a file in memory for user to download, but not through server?)

For PDF, it might be easier to use a library. For .NET, Best Server-side .NET PDF editing library should give you a good solution. There is also a JAVA version of it.


If you are looking to export the chart as well, CSV does not support this.

For PDF, you could export your canvas to a data URI (see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
and use a client side library like jspdf (see How to add Image in jspdf? for an example) or do the same thing on the server using iText / iTextSharp (see Inputting image data to PDF with iText)

Leave a comment