Click here to Skip to main content
13,048,584 members (90,934 online)
Rate this:
Please Sign up or sign in to vote.
Hey I was wondering if anybody knew how to save charts as an image, preferrable pdf. I have a chart dynamically created and have tried a couple things including the following.
protected void btnSaveImage_Click(object sender, EventArgs e)
            chrAdvertising.SaveImage( chrAdvertising.CurrentImageLocation, ChartImageFormat.Png);
            CommonHelper.WriteResponseImage(Server.MapPath("~/TempImages/" + chrAdvertising.CurrentImageLocation), "defaultName.png");

With chart code starting as
<asp:Chart ID="chrAdvertising" runat="server" BackColor="211, 223, 240" ImageUrl="~/TempImages/ChartPic_#SEQ(300,3)"

Where chrAdvertising is the name of the chart and commonhelper.writeResponseImage brings up a window directing the user to where you can save the image (which works with other images already on the server). The problem is the image isn't acutally stored in the TempFolder I assigned it. If you have a better understanding of the chart feature and where the image is stored between postbacks or if it is lost between postbacks, please explain.

Also if you know how to convert the image to pdf that would save me from asking a seperate question :)
Thanks ~MJ
Posted 16-Sep-11 10:49am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


What you want to do exactly.

You've image and then you've write it in pdf file right.

you can write any thing in pdf files in by using iTextSharp library

If you don't've idea on iTextSharp checkout links for sample codes.

and there is a open source pdf library for

checkout those two links you can get clear idea on handling pdf files in

you can add text,image and charts to PDF file.

Here you are using some tempfolder for saving charts right its better to use session variable or application variable for storing charts

It can easy accessable and easily deletable.

try steps mentioned in above links you'll get good output.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 16 Sep 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100