Printing chart using TempChart=Session

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Joe
Newbie
Newbie
Posts: 12
Joined: Thu Apr 15, 2004 4:00 am

Printing chart using TempChart=Session

Post by Joe » Thu Jul 01, 2004 2:27 am

I have a WebChart which displays fine but fails to print. TempChart is set to Session, and my GetChart.aspx Page_Load is adapted from Tutorial 9 as follows:

private void Page_Load(object sender, System.EventArgs e)
{
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
System.IO.MemoryStream chartStream = new System.IO.MemoryStream();
chartStream=((System.IO.MemoryStream)Session[chartName]);
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
//chartStream.Close();
//Session.Remove(chartName);
}
}

Note that I don't close the stream or remove it from the session since the print operation will request the same chart. On trying to print any page that includes a WebChart, the chart does not print and, even worse, other session data is either removed or overwritten.

Vincent Frisina
Synapcent

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jul 01, 2004 11:20 pm

Hi Vincent,

does the example included in the TeeChart for Net v1 installation under :
C:\Program Files\Steema Software\TeeChart for .NET v1\TeeChartForNET\WebForm works fine for you ?

Joe
Newbie
Newbie
Posts: 12
Joined: Thu Apr 15, 2004 4:00 am

Post by Joe » Fri Jul 02, 2004 4:23 am

The example code does not work for me. The code I had originally posted was that exact code with the line to close and remove the stream removed so that the stream would still be open and available when the browser print operation requested the stream again. With or without closing the stream, my session state is lost when I try to print a page containing a web chart.

What I am most concerned about is that simply trying to print any page that inclues a webchart causes me to loose my session state.

I also experimented with simply returning from my Page_Load method without manipulating the stream in case I was doing something wrong there. Of course, the chart did not display since I never sent the data to the client, but I saw I was still losing my session state. I then trimmed down even further by not adding any data or in any way manipulating web chart on the page I was trying to print. All it showed was the default empty chart. However, when I tried to print the page containing that web chart my session state was again lost and the chart did not print.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Jul 06, 2004 11:53 am

Hi Vicent,

I'm using the latest TeeChart for .NET, version 1.1.1644.16795.

In a new ASP.NET app I added in the standard GetChart.aspx. I then added a WebChart to WebForm1.aspx and set the TempChart property to "Session". I then added the following code to WebForm1:

Code: Select all

private Steema.TeeChart.Chart Chart1;
	
private void Page_Load(object sender, System.EventArgs e)
{
	Chart1 = WebChart1.Chart;
	MemoryStream tmpChart=new MemoryStream();

	Chart1[0].FillSampleValues(20);

	if (Session["Chart1"]==null) {
		Chart1.Export.Template.Save(tmpChart);
		Session.Add("Chart1",tmpChart);
	}
	else {
		tmpChart=(MemoryStream)Session["Chart1"];
		tmpChart.Position=0;
		Chart1.Import.Template.Load(tmpChart);
	}
}
I then run this project and selected IE's File->Print... menu option. I then printed to a PDF file using a free printer driver available from http://www.pdf995.com/download.html. I have uploaded the results to news://www.berneda.com/steema.public.attachments.

Are you able to reproduce this behaviour at your end?
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply