Exporting Chart into a PDF Format

To export chart to the bitmap image and create the PDF with the image using C1Pdf library, use the following code:

// save chart image to stream

    MemoryStream ms = new MemoryStream();

    chart.SaveImage(ms, ImageFormat.Png);

 

    // create image instance from stream

    var img = System.Drawing.Image.FromStream(ms);

 

    // create and save pdf document

    C1PdfDocument pdf = new C1PdfDocument();

    pdf.DrawImage( img, new System.Drawing.RectangleF(0,0,img.Width,img.Height));

    pdf.Save("doc.pdf");


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.