Printing multiple charts with a single Print Preview Dialog

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Arction_LasseP

Posts: 7
Joined: Tue Oct 24, 2017 9:39 pm

Printing multiple charts with a single Print Preview Dialog

Post by ussainik » Mon Mar 26, 2018 7:18 pm

I have a requirement where I need to print multiple charts at once with just one print preview dialog. Right now I am using the Print method provided by you and it directly prints all the charts at once without a print setup dialog.

On the other hand if I call the Print Preview method inside my loop it brings up multiple dialogues but I want only one. Is there an option in Lightning Charts to do it. Here is my full code. I am getting a Dictionary of charts where key is the single chart.

Code: Select all

private void PrintAllCharts(Dictionary<LightningChartUserControl, string> charts)
				if (PrinterSettings.InstalledPrinters.Count == 0)
							"Default printer not found", MessageBoxButton.OK, MessageBoxImage.Error);
				for (int i = 0; i < charts.Count; i++)
					KeyValuePair<LightningChartUserControl, string> kp = charts.ElementAt(i);
					kp.Key.Chart.Print(ImageType.Vector, false, true, false, kp.Value, string.Empty, true, new Thickness(0, 20, 0, 0));
				PrinterSettings settings = new PrinterSettings();
						"Print Successful", MessageBoxButton.OK);
			catch (Exception ex)

Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Printing multiple charts with a single Print Preview Dia

Post by ArctionKestutis » Tue Mar 27, 2018 1:44 pm


PrintPreview is per chart. There is no easy way to do otherwise. I believe that best workaround is to save chart as image and combine those images into single printable page.
You can create bitmap or vector image with SaveToFile(), SaveToStream(), CopyToClipboard(…), CopyToClipboardAsEmf() calls or even CaptureToByteArray method (see chapter 12.Export and printing for brief description). Raster image (*.PNG, *.JPG, *.TIF, *.BMP formats) will create one-to-one copy of the chart, while Vector image format will be not identical, but more easily scalable.
The approach we are talking was iliustrated in our WinFroms Demo App example (XY -> Dashboards) “Chart in chart”. You create main chart with annotations, and place bitmap (Fill) inside those annotations. Each annotation is individual chart.

Hope this helps.
All the best.