I want to create a temporary chart and export it immediately to PDF, without showing it to the user.
I use following code to do this:
Code: Select all
Steema.TeeChart.TChart tChart2 = new Steema.TeeChart.TChart();
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart2.Chart);
line1.Add(0, 0, "Category 1");
line1.Add(1, 20, "Category 2");
line1.Add(2, 30, "Category 3");
// Steema.TeeChart.Export.PNGFormat pngFormat = tChart2.Export.Image.PNG;
// pngFormat.Width = 1024;
// pngFormat.Height = 576;
// pngFormat.Save("test.png");
Steema.TeeChart.Export.PDFFormat pdfFormat = tChart2.Export.Image.PDF;
pdfFormat.Width = 1024;
pdfFormat.Height = 576;
pdfFormat.Save("test.pdf");
However, when I export the chart to PNG, the resulting PNG file correctly shows the chart as it should be.
Also, when first exporting the chart to PNG and then to PDF right after that (by uncommenting the code above), the resulting PDF also correctly shows the chart as it should be.
Did I forget some kind of initialization step before exporting the chart to PDF, which is automatically done when exporting the chart to PNG first?
Best regards,
Steven