Page 1 of 1

Tutorial for .Net creating PDF from Charg

Posted: Sun Jul 01, 2018 9:39 pm
by 8125091
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.

Re: Tutorial for .Net creating PDF from Charg

Posted: Mon Jul 02, 2018 7:25 am
by Christopher
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 25117 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 );
      }
    }

Re: Tutorial for .Net creating PDF from Charg

Posted: Thu Jul 12, 2018 4:41 pm
by 8125091
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.

Re: Tutorial for .Net creating PDF from Charg

Posted: Thu Jul 12, 2018 5:16 pm
by 8125091
P.S. I just wanted to clarify we are using this for a web application and not a desktop.

Re: Tutorial for .Net creating PDF from Charg

Posted: Fri Jul 13, 2018 7:29 am
by Christopher
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.

Re: Tutorial for .Net creating PDF from Charg

Posted: Sat Jul 14, 2018 3:34 am
by 8125091
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

Re: Tutorial for .Net creating PDF from Charg

Posted: Mon Jul 16, 2018 8:25 am
by Christopher
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.

Re: Tutorial for .Net creating PDF from Charg

Posted: Sat Jul 21, 2018 5:35 pm
by 8125091
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.

Re: Tutorial for .Net creating PDF from Charg

Posted: Mon Jul 23, 2018 7:41 am
by Christopher
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."

Re: Tutorial for .Net creating PDF from Charg

Posted: Mon Jul 23, 2018 3:07 pm
by 8125091
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!

Re: Tutorial for .Net creating PDF from Charg

Posted: Tue Jul 24, 2018 7:54 am
by Christopher
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?

Re: Tutorial for .Net creating PDF from Charg

Posted: Tue Jul 24, 2018 4:12 pm
by 8125091
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

Re: Tutorial for .Net creating PDF from Charg

Posted: Thu Jul 26, 2018 11:39 am
by Christopher
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