Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 ASP.NET PDF Chart
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 asp.net 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 Smile | :)
Thanks ~MJ
Posted 16-Sep-11 11:49am
MJ_263

1 solution

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

Solution 1

Hi
 
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 asp.net by using iTextSharp library
 
If you don't've idea on iTextSharp checkout links for sample codes.
 
http://www.developerfusion.com/code/5682/create-pdf-files-on-fly-in-c/
 
and there is a open source pdf library for asp.net
 
http://www.webresourcesdepot.com/open-source-pdf-library-for-aspnet-pdfsharp/
 
checkout those two links you can get clear idea on handling pdf files in asp.net
 
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 BillWoodruff 220
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,817
2 DamithSL 5,461
3 Manas Bhardwaj 4,946
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 16 Sep 2011
Copyright © CodeProject, 1999-2014
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