Nevron Forum

how to print chart on PrintDocument?

https://www.nevron.com/Forum/Topic14388.aspx

By yunhyung jeon 1 - Wednesday, April 13, 2022

hello

I'm using Nevron .NET Chart at .net 5.0, winform.

However, I have some questions.
I want to print my Nevron Chart, so, I'm using C#'s PrintDocument PrintPage event.
But, my chart do not shown at print preview page.

Here is my chart print code.

      NRectangleF chartBounds = new NRectangleF(headerBounds.Left, headerBounds.Bottom, headerBounds.Width, CompHeight * 8);
      NChartPrintView chartView = new NChartPrintView(nChartControl.PrintManager, nChartControl.Document, ev.Graphics);
      chartView.Print(chartBounds);
      chartView.Dispose();


First image is my origin chart at runtime. Second Image is my printview image.
When I draw just small data, printview page is well. But, If I draw many datas, my chart are not shown like these images.
How can I fix it?




By Nevron Support - Wednesday, April 13, 2022

Hi,

Please send the state of the control for review. To save the control state you can use:

nChartControl1.Serializer.SaveControlStateToFile("c:\\temp\\chartstate.xml", Nevron.Serialization.PersistencyFormat.XML, null);

Let us know if you meet any problems...
By yunhyung jeon 1 - Wednesday, April 13, 2022

Okay, here is my chart's state file.

I hope the problem will be solved soon.
Thank you.
By Nevron Support - Tuesday, April 19, 2022

Hi Yunhyungjeon,

Thank you for sending the save file. We investigated the issue and indeed the control is printing properly, but only when the amount of data is low. We suspect this is caused by a problem in Windows and the workaround is to create a high res raster, which in turn can be printed:
Bitmap bitmap = new Bitmap(2000, 2000, printerGraphics);
nChartControl1.ImageExporter.RenderToBitmap(bitmap, false);
// you can draw the bitmap to the printerGraphics here
bitmap.Dispose();

We hope this helps - let us know if you meet any problems or have any questions.