hi
i need a simple pie chart which is easy for
exporting to pdf...
how to use asp chart...is that easy to export to pdf...
suggest me some examples ...
Thank you
You can do that using the buiilt-in chart controls and iTextSharp: http://www.mikesdotnetting.com/Article/115/Microsoft-Chart-Controls-to-PDF-with-iTextSharp-and-ASP.NET-MVC
Hi,
It doesn't matter and usually you don't need to care. We take the output of your Grid or Chart and "display it on a PDF paper" exactly the same way your browser display it on the screen. So if your browser can display it, we will be able to convert it. One
notable exception to this is if your chart uses Flash, then we won't be able to convert it because we do not load third party plugs.
Refer
http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview-data-to-pdf.html
Hi,
As @Mikesdotnetting said, please try to use the iTextSharp to meet your requirement.
In the .aspx:
Populating the Chart:
protected void Page_Load(object sender, EventArgs e)
{
string[] x = new string[4] { "Mango", "Apple", "Orange", "Banana" };
int[] y = new int[4] { 200, 112, 55, 96 };
Chart1.Series[0].Points.DataBindXY(x, y);
Chart1.Series[0].ChartType = SeriesChartType.Pie;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart1.Legends[0].Enabled = true;
}
Exporting the ASP.Net Chart to PDF:
On the click of the Export Button the following event handler is executed which exports the ASP.Net Chart to PDF:
protected void btnExportPDF_Click(object sender, EventArgs e)
{
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
using (MemoryStream stream = new MemoryStream())
{
Chart1.SaveImage(stream, ChartImageFormat.Png);
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();
}
}
Best Regards.
沒有留言:
張貼留言