Export multiple charts to PDF using iTextSharp Library in ASP.Net

vivek
 
on Jan 30, 2013 01:31 AM
6238 Views

Hi, How do i export multiple charts to pdf using iText library? Could you please provide me with a sample example?

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mustafa
 
on Feb 01, 2013 02:04 AM
on Feb 01, 2013 02:06 AM

Using the above link i have created the sample code

 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);
            for (int IntLocI = 1; IntLocI <= 2; IntLocI++)
            {
                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();
        }
    }

This code creates the two charts in one PDF Document