I'm currently adding print functionality to my WPF application. To do this I'm using the function below which takes in a visual element, scales it to ensure that it will fit on a paper page, then prints using PrintDialog.PrintVisual(...)
This works fine except when it comes to Telerik charts. For example when I try to scale and print a Scatter Spline chart the dots are drawn in the correct position, but the connecting spline is drawn offset to the right, the offset is worse when the chart is scaled to fit a portrait page. I have attached three images, the first showing the correct chart, the second showing how the chart prints in landscape view, and the third showing how the chart prints in portrait view. The printed images were captured using CutePDF but I get the same results printing to printers.
private void ScalePrint(Visual visual, string printingTitle = null)
System.Windows.FrameworkElement e = visual as System.Windows.FrameworkElement;
if (e == null)
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == true)
//store original scale
Transform originalScale = e.LayoutTransform;
//get selected printer capabilities
System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);
//get scale of the print wrt to screen of WPF visual
double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / e.ActualWidth, capabilities.PageImageableArea.ExtentHeight /
//Transform the Visual to scale
e.LayoutTransform = new ScaleTransform(scale, scale);
//get the size of the printer page
System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
//update the layout of the visual to the printer page size.
e.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
//now print the visual to printer to fit on the one page.
//apply the original transform.
e.LayoutTransform = originalScale;
Do you know of a way to scale the charts to the size of the page correctly for printing, or do I need to use a separate print method. Please note that in many cases the chart will need to be printed along with other controls on the page; there will be very few, if any, instances of a chart being printed on its own.
Thanks for the help.