This is a migrated thread and some comments may be shown as answers.

Custom RadDiagram appearance (styles) for Printing

3 Answers 40 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 03 Mar 2015, 07:41 PM
Hello!

How can I change RadDiagramm appearance in PrintPreview dialog? I was try to make new instance of RadDiagram with custom styles, but it is does not work. PrintPreview is empty. Can you send example, which describe, how to print diagram with custom shape/link styles for printing puporses. Thank you.

void PrintClick(object sender, ItemClickEventArgs e)
        {
            var printPreviewWindow = new Window();
            var diagramForPrint = new RadDiagram();
            diagramForPrint.GraphSource = diagramm.GraphSource;
            diagramForPrint.Style = diagramm.Style;//here I will set some my PrintStyle
            var printPreview = new RadDiagramPrintPreview() { Diagram = diagramForPrint };
            printPreviewWindow.Content = printPreview;
            printPreviewWindow.ResizeMode = ResizeMode.NoResize;
            printPreviewWindow.Width = 800;
            printPreviewWindow.Height = 600;
            printPreviewWindow.ShowDialog();
        }

3 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 04 Mar 2015, 02:09 PM
Hello Max,

You can find information on how to print the RadDiagram in our online documentation. This approach will print your diagram which is definer in XAML as you are setting the diagram property of the
RadDiagramPrintPreview control to the same instance as the diagram defined in XAML.

However if you want to create a new RadDiagram instance in code behind and try to print it will be displayed as empty page as the diagram is not in the VisualTree and it has never been rendered. If you want to print a RadDiagram this way you will need to manually Measure and Arange it inside a parent control. Here is a modified version of your code snippet:
var printPreviewWindow = new Window();
        var diagramForPrint = new RadDiagram();
        diagramForPrint.GraphSource = diagramm.GraphSource;
        //diagramForPrint.Style = diagramm.Style;//here I will set some my PrintStyle
 
        var userControl = new UserControl();
        userControl.Content = diagramForPrint;
        diagramForPrint.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
        diagramForPrint.Arrange(new Rect(0, 0, diagramForPrint.DesiredSize.Width, diagramForPrint.DesiredSize.Height));
 
        var printPreview = new RadDiagramPrintPreview() { Diagram = diagramForPrint };
        printPreviewWindow.Content = printPreview;
        printPreviewWindow.ResizeMode = ResizeMode.NoResize;
        printPreviewWindow.Width = 800;
        printPreviewWindow.Height = 600;
        printPreviewWindow.ShowDialog();

If this approach does not work for you, could you please elaborate with more information on your scenario, describing the steps that you want to make and the end result. Also a sample project demonstrating the way you are trying to print the diagram will help us better understand your scenario.

I hope this information helps.

Kind regards,
Kiril Vandov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Eric
Top achievements
Rank 1
answered on 09 Sep 2019, 07:02 PM

Hi There,

Another approach is to restyle tie displayed graph while printing and then restore the default styling upon completion. I needed to change the edge colors from white to black for printing and this approach worked fine.

-Eric G.

 

0
Martin Ivanov
Telerik team
answered on 10 Sep 2019, 05:27 AM

Hello Eric,

Thank you for sharing this approach.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Diagram
Asked by
Max
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Eric
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or