Tutorial for .Net creating PDF from Charg

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

Tutorial for .Net creating PDF from Charg

Post by Joe » Sun Jul 01, 2018 9:39 pm

For the .Net tutuorial we did not see mention of how to create PDF from the charts. The is an explanation for other areas platforms. Does anyone know where to find info on how to create PDF from TeeChart .Net? Thank you.

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Mon Jul 02, 2018 7:25 am

Hello!

yes, there's an example of how to export to PDF in the Features Demo shipped with the TeeChart.NET Pro version:
TeeChartNetExamples_2018-07-02_09-21-35.png
TeeChartNetExamples_2018-07-02_09-21-35.png (202.45 KiB) Viewed 2461 times
the code in the 'Save to PDF' button looks like this:

Code: Select all

    private void button1_Click(object sender, System.EventArgs e)
    {
      saveFileDialog1.DefaultExt = tChart1.Export.Image.PDF.FileExtension;
      saveFileDialog1.FileName = tChart1.Name+ "."+saveFileDialog1.DefaultExt;
      saveFileDialog1.Filter=Texts.PDFFilter;
      if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
      {
        tChart1.Export.Image.PDF.Save( saveFileDialog1.FileName );
      }
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Thu Jul 12, 2018 4:41 pm

Christopher

Thank you very much for your detailed response.

We were able to get the PDF to work; however, we are trying to capture a color teechart with a legend. The resulting PDF contains only one part of the legend. The legend has 2 parts and then there is the chart. Here is a link to a screen shot. Only the part shaded yellow is included in PDF. Is each part considered an image. If so, what is the code for multiple images.

https://www.dropbox.com/s/tlqs3js19ffpw ... t.jpg?dl=0

Thank you.

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Thu Jul 12, 2018 5:16 pm

P.S. I just wanted to clarify we are using this for a web application and not a desktop.

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Fri Jul 13, 2018 7:29 am

Hello,

is there any chance you can pass me the code you use to create your Chart? It would be much easier to help you if I could reproduce your issue here.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Sat Jul 14, 2018 3:34 am

Below is a link to a Word Document containing code for 2 graphs using TeeChart. Highlighted in yellow is what we are using to get the PDF.

I hope this is what you need. If you need the entire code for the application, providing that would not be easy.

I hope you can help, we would really like to use TeeChart for the chart and creating a PDF.

Here is link to the document:
https://www.dropbox.com/s/gzy8rebuh7fi8 ... .docx?dl=0

Thank you,

Joe

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Mon Jul 16, 2018 8:25 am

Hello Joe,

thanks for the code. With respect to reproducing your issue here, when you say, 'the legend has 2 parts and then there is the chart,' which two parts of the legend are you referring to? I'm afraid I can't see any code in your images which refers to a second part of the legend.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Sat Jul 21, 2018 5:35 pm

Here is a screen shot of the chart: https://www.dropbox.com/s/k3zeh4q3hs9jo ... t.jpg?dl=0

I have labled the three parts. The big part is #1, the score/can't do/wont do is part 2, and below average--average, above avg, is part 3.

When we use your code we only get part 2 the part marked in yellow. So the teechart may create all 3 as ONE part but we only get what I have labeld part 2 when creating a pdf of the chart that shows all 3 parts on the page.

Make sense?

Thanks for staying with us on this.

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Mon Jul 23, 2018 7:41 am

synapcent wrote: Make sense?
I think so. If I understand you correctly, your issue is that the graphical objects with the labels "Above Average", "Average", and "Below Average" are appearing in your WebForm chart but not in your pdf.

My issue is that the image of the code you linked to in this post does not contain the words "Above Average", "Average", nor "Below Average". I've looked half a dozen times at the image but I cannot see any reference to these words: if this code was text instead of an image I could search it for these terms to be absolutely sure they are not there. Even so, I'm pretty sure the code you sent me makes no reference to these words and so makes no reference to how these graphical objects got painted on your Chart.

This is what I meant when I said, "I'm afraid I can't see any code in your images which refers to a second part of the legend."
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Mon Jul 23, 2018 3:07 pm

It is not so important to include parts 2 and 3 which are something like a legend. We want to get part 1 which is the main chart in the PDF. We can go without the other two parts. Currently we are getting only one part and that is not the main chart. Thank you!

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Tue Jul 24, 2018 7:54 am

synapcent wrote:It is not so important to include parts 2 and 3 which are something like a legend. We want to get part 1 which is the main chart in the PDF. We can go without the other two parts. Currently we are getting only one part and that is not the main chart. Thank you!
Using the code you posted I can successfully export parts 1 and 2 to pdf. Which version of TeeChart.dll are you using?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

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

Re: Tutorial for .Net creating PDF from Charg

Post by Joe » Tue Jul 24, 2018 4:12 pm

We are using this build teechart .net pro
TeeChart.Net build 4.1.2015.08065

We have downloaded but have not installed this version: TeeChartNET2017_4.1.2017.10190.exe

Are these versions capable of producing PDF from TeeCharat?

Thank you

Christopher
Guru
Posts: 1176
Joined: Fri Nov 15, 2002 12:00 am

Re: Tutorial for .Net creating PDF from Charg

Post by Christopher » Thu Jul 26, 2018 11:39 am

Hello!

Using the 2017 version, I use the following code:

Code: Select all

		protected void Page_Load(object sender, EventArgs e)
		{
			//Let's work with the Chart object for convenience      
			Steema.TeeChart.Chart Chart1 = WebChart1.Chart;
			//Add in a series and fill it      
			Chart1.Aspect.View3D = false;

			for (int i = 0; i < 3; i++)
			{
				Chart1.Series.Add(typeof(Line)).FillSampleValues();
			}

			Chart1.Header.Text = typeof(Chart).Assembly.GetName().Version.ToString();
		}

		protected void Button1_Click(object sender, EventArgs e)
		{
			string path = @"C:\tmp\webchart.pdf";
			Steema.TeeChart.Chart Chart1 = WebChart1.Chart;
			Chart1.Export.Image.PDF.Save(path);
			Process.Start(path);
		}
and obtain the following result:

Image
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply