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?