-1

I am using ChartNew.js for Horizontal Stacked bar report. I am not sure how to export chart report to PDF and CSV format with ChartNew.js?

I tried but could not find any solution. Any help with sample code would highly appreciated.

cssyphus
  • 37,875
  • 18
  • 96
  • 111
Joy1979
  • 599
  • 5
  • 12
  • 23

1 Answers1

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)

Community
  • 1
  • 1
potatopeelings
  • 40,709
  • 7
  • 95
  • 119