Exporting Support

With the Q2 2013 release of RadGanttView the control provides an image exporting mechanism which enables its printing functionality.

The exporting functionality is simple and all you need to do is pass the desired image size, printable areas etc. to the built-in exporting service which would generate images containing the contents of the control. The exporting functionality supports exporting the controls GridView area, TimeLine area or both. It is also customizable to include or exclude the Headers of the control.

The built-in exporting to images functionality of the RadGanttView control works in the following matter. By calling the ExportingService.BeginExporting method of the control you will need to pass an object of type ImageExportSettings. The BeginExporting method returns an object of ImageExporter type which holds a collection of wrappers which are used to export the BitmapSource. Then next screenshot shows the principal with which the images are exported by the ExportingService:


Export for Printing

The next example will demonstrate how to export the contents of the RadGanttView control in order for them to be printed on A4 format.

Note: Before proceeding with the next example you should get familiar with Implementing View-ViewModel

  1. First you should create a collection of GanttTasks, in the ViewModel and populate it with some sample data.

  2. Create a DateRange object for the VisibleRange property and set in in the ViewModel.

  3. Next we need to create a PrintingService class that will handle the printing functionality with the use of a PrintDocument:

        public static class PrintingService 
            public static void Print(RadGanttView ganttView) 
                var isFirstPass = true; 
                var exportImages = Enumerable.Empty<BitmapSource>(); 
                var enumerator = exportImages.GetEnumerator(); 
                var pd = new PrintDocument(); 
                pd.BeginPrint += pd_BeginPrint; 
                pd.PrintPage += (s, e) => 
                    if (isFirstPass) 
                        var printingSettings = new ImageExportSettings(e.PrintableArea, true, GanttArea.AllAreas); 
                        using (var export = ganttView.ExportingService.BeginExporting(printingSettings)) 
                            exportImages = export.ImageInfos.ToList().Select(info => info.Export()); 
                            enumerator = exportImages.GetEnumerator(); 
                        isFirstPass = false; 
                    e.PageVisual = PrintPage(enumerator.Current); 
                    e.HasMorePages = enumerator.Current != null; 
            static void pd_BeginPrint(object sender, BeginPrintEventArgs e) 
            private static UIElement PrintPage(BitmapSource bitmap) 
                var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight); 
                var image = new System.Windows.Controls.Image { Source = bitmap }; 
                image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize)); 
                return image; 
  4. Finally we need to create a button that will make use of the newly created PrintingService class:

        <Grid DataContext="{StaticResource ViewModel}"> 
            <telerik:RadButton x:Name="PrintButton" Click="PrintButtonClick" Content="Print" /> 
            <telerik:RadGanttView x:Name="GanttView"> 

        private void PrintButtonClick(object sender, RoutedEventArgs e) 

Find a runnable project of the previous example in the WPF Samples GitHub repository.

The next screenshots show the final result:

  1. The RadGanttView control with the Print button:


  2. The default printing dialog that is opened from the Print button:


  3. The generated .oxps file:


In this article