Printing Gantt Charts with custom page template

Many developers have asked us in the past to provide a way to enable further printing customizations, i.e. adding the ability to set up specific page headers and footers for output pages and automatically shrinking output content size and repaginating the document without losing printing quality.

We have good news, everybody: we have recently added new PrintingTemplate properties to all controls in DlhSoft Gantt Chart Light Library (both for Silverlight and WPF), and you can now customize printing easier than you might have thought before! We don’t only support page headers and footers, but you can now fully customize the visuals in the page as if they were on screen, using a common XAML-defined template, and simply adding a placeholder somwhere inside for the chart content that is to be printed by the component itself.

As WPF and Silverlight always use templates in order to allow developers to customize screen views, it’s a terrible waste that this concept hasn’t yet been utilized for printing in the Framework itself. Regardless, as usually Gantt Charts really need to be printed, we have added this feature in our own library ourselves.

For example, you can set up the PrintingTemplate property value of a GanttChartDataGrid control instance using plain XAML code as indicated below (the ContentPresenter object included within the template represents the required place holder for printing chart contents):

        <Grid Margin=”32″>
            <TextBlock Grid.Row=”0″ FontWeight=”Bold”
Text=”GanttChartDataGrid Sample”/>
            <Border Grid.Row=”1″ Margin=”0,16″ BorderBrush=”DarkGray”
                <ContentPresenter Content=”{Binding Content}”/>
            <StackPanel Grid.Row=”2″ Orientation=”Horizontal”
                <TextBlock Text=”{Binding PageIndex}”/>
                <TextBlock Text=”/”/>
                <TextBlock Text=”{Binding PageCount}”/>

Moreover, as you have probably noticed from the XAML code, you can also use some page parameters (commonly used with bindings); here is the full list:

  • PageIndex: the number of the current page in the printing document;
  • PageCount: the total number of pages in the printing document;
  • HorizontalPageIndex: the number of the current page in the horizontal layout of the printing document (pages that can be positioned on top of each other share the same HorizontalPageIndex value);
  • HorizontalPageCount: the total number of pages in the horizontal layout of the printing document;
  • VerticalPageIndex: the number of the current page in the vertical layout of the printing document (pages that can be positioned to the side of each other share the same VerticalPageIndex value);
  • VerticalPageCount: the total number of pages in the vertical layout of the printing document.

Finally, you just need to call the Print method of the control to get the customized document sent to a printer (the end user can select it in the common Print dialog window that opens).


About DlhSoft Team

DlhSoft is a software development company focused on building high quality and innovative solutions using Microsoft® .NET and related technologies for customers worldwide. Our activity includes designing and developing general purpose software applications, components and tools, and customized software solutions upon request. DlhSoft team is highly experienced and fully dedicated to software development. The complete set of knowledge, skills, and abilities of its members is guaranteed by the individually assessed Microsoft® certifications. Additionally, one of the most important things we rely on is the continuous communication with the customer; all the feedback we receive is very valuable to us.
This entry was posted in Development Components and tagged , , , , , . Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s