0

i have code for printing normal piecharts using iTextSharp.dll (pdf generating lib)

namespaces used:

using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Web.UI.DataVisualization.Charting;

code:

Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    using (MemoryStream stream = new MemoryStream())
    {
        PieChart1.SaveImage(stream, ChartImageFormat.Png);  //error line
        iTextSharp.text.Image chartImage = iTextSharp.text.Image.GetInstance(stream.GetBuffer());
        chartImage.ScalePercent(75f);
        pdfDoc.Add(chartImage);
        pdfDoc.Close();

        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=Chart.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Write(pdfDoc);
        Response.End();
    }

But this code dosen't work for ajax pie charts, it show error:

Error 1 'AjaxControlToolkit.PieChart' does not contain a definition for 'SaveImage' and no extension method 'SaveImage' accepting a first argument of type 'AjaxControlToolkit.PieChart' could be found (are you missing a using directive or an assembly reference?)

also is there any other way like printing piechart's div from javascript? or any other code sample/reference?

Ashish Upadhyay
  • 25
  • 1
  • 10

1 Answers1

-1

if you want to perform action from javascript. i would suggest you to use Highcharts it is best for all types of charts and also it gives builtin print and download as image or PDF. http://www.highcharts.com/demo/pie-basic check this link and demo it is user friendly and light weight.

Pang
  • 9,564
  • 146
  • 81
  • 122
UsmanMirza
  • 278
  • 1
  • 8