Issue with chart printing

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Issue with chart printing

Post by porterbe » Wed Oct 27, 2010 3:57 pm

I have a requirement to output to a print document, which is working to a point with the following code:

Code: Select all

            
            Stream CO2PlotStream = new MemoryStream();
            tcCO2Plot.Export.Image.PNG.Save(CO2PlotStream);
            Image CO2PlotImage = Image.FromStream(CO2PlotStream);
This is then drawn on the print engine in the OnPrint event where Bounds is the calculated page bounds.

Code: Select all

            
            e.Graphics.DrawImage(Image, Bounds);
However, the image appears fuzzy - see the attached screenshot of the resultant document in PDF form.
PDF Report ScreenCap.png
Extract from Print call
PDF Report ScreenCap.png (87.78 KiB) Viewed 4214 times
Contrast with a clipboard copy to Word and PDF - The clipboard copy is generated with the following code

Code: Select all

            Chart.Export.Image.Metafile.CopyToClipboard();
And produces the following when PDFd (and screen cap'd)...
PDF Clipboard ScreenCap.png
PDF Clipboard ScreenCap.png (55.87 KiB) Viewed 4189 times
Any suggestions as to how I can improve the printing to be more like the copy?

TIA Bernie

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with chart printing

Post by Sandra » Thu Oct 28, 2010 10:10 am

Hello Bernie,

I think you can use different formats of Metafile, allowing you export higher quality images. You can do something as next:

Code: Select all

 private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfOnly;
            tChart1.Export.Image.Metafile.Save(@"teeChartEmfOnly.emf");


            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusDual;
            tChart1.Export.Image.Metafile.Save(@"teeChartEmfPlusDual.emf");

            tChart1.Export.Image.Metafile.EMFFormat = System.Drawing.Imaging.EmfType.EmfPlusOnly;
            tChart1.Export.Image.Metafile.Save(@"teeChartEmfPlusOnly.emf"); 
        }
Also, If you prefer use CopyToClipBoard() method, I recommend you use PNG format,so get a good results when do this. See next example:

Code: Select all

 private void InitializeChart()
        {
            Steema.TeeChart.Styles.ErrorBar series1 = new Steema.TeeChart.Styles.ErrorBar(tChart1.Chart);
            tChart1.Aspect.View3D = false;
            series1.FillSampleValues();
            series1.ColorEach = true;
            tChart1.Export.Image.PNG.CopyToClipboard();
        }
I hope will helps.

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

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Issue with chart printing

Post by porterbe » Thu Oct 28, 2010 10:43 am

Hi Sandra,

The clipboard copy is working fine - the issue is with the printed output. Now, I'm a bit of a newbie at printing in C#, but it seems to me that I need an Image object to pass to the Graphics.DrawImage method in the PrintDocument OnPrint event handler. I'm generating this image using the tcChart.Export.Image method into a memory stream, then creating an image object from that. Now, Graphics.DrawImage is scaling the image to fit the specified bounds, but that is not the root cause of the problem - using Graphics.DrawImageUnscaled generates this.
PDF Report ScreenCap Unscaled.png
PDF Report ScreenCap Unscaled.png (93.15 KiB) Viewed 4165 times
As you can see, this is still blury although the font proportions are now better. I think I need to be able to control the size of the image I generate - is this possible? Or do you have a better way of getting something I can use with a Graphics object?

As usual, all suggestions appreciated!

Bernie

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with chart printing

Post by Sandra » Thu Oct 28, 2010 1:00 pm

Hello Bernie,

You could change size of image you would export, using properties Width and Height of Image as do in below code:

Code: Select all

            tChart1.Export.Image.PNG.Width = 200;
            tChart1.Export.Image.PNG.Height = 100;
            tChart1.Export.Image.PNG.CopyToClipboard();
I hope will helps.

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

Post Reply