- 3 minutes to read
This topic explains what the printing links are and how they are used to create documents that are ready to be previewed, printed and exported.
This topic consists of the following sections.
DXPrinting creates documents by linking data with templates (DataTemplate).
Depending on data provider, templates are either provided by a link or by an associated control (e.g., when printing DevExpress grids).
Using Links to Print Data
To create a document and publish it (print, export, or show it in a Document Preview window), perform the following steps.
- Create a link according to the type of data (SimpleLink, CollectionViewLink or PrintableControlLink);
- Call the required method of the PrintHelper class with the link instance passed to this method as a parameter.
- report header (TemplatedLink.ReportHeaderData and TemplatedLink.ReportHeaderTemplate);
- page header (TemplatedLink.PageHeaderData and TemplatedLink.PageHeaderTemplate);
- page footer (TemplatedLink.PageFooterData and TemplatedLink.PageFooterTemplate);
- report footer (TemplatedLink.ReportFooterData and TemplatedLink.ReportFooterTemplate);
The following link types are available in DXPrinting.
SimpleLink is used to create documents based on plain linear data. Its essential members are:
- the SimpleLink.DetailTemplate property, which specifies a template for each data row (detail data);
- the SimpleLink.DetailCount property, which specifies the number of detail records (the number of times the CreateDetail event is raised to create a document detail area);
- the SimpleLink.CreateDetail event, which is raised for each detail record created and which also allows for the providing of data for the document detail area.
For a code example, see How to: Use the Simple Link.
Apart from the CollectionViewLink.DetailTemplate property, this link type provides the CollectionViewLink.GroupInfos property. This option allows you to specify distinct templates for GroupInfo.HeaderTemplate and GroupInfo.FooterTemplate properties, so that you can set off each grouping level within a document in a different style.
In addition, the GroupInfo.RepeatHeaderEveryPage property defines whether a group header is repeated on each page.
For a code example, see How to: Use the CollectionView Link.
When printing a grid, a link can be created based on the grid’s TableView.
This special link type supports the creation of multi-column documents (where data is arranged on a page in several columns), by using its TemplatedLink.ColumnLayout and TemplatedLink.ColumnWidth properties.
- LegacyPrintableComponentLink is intended to print DevExpress controls for Windows Forms that implement the IPrintable interface.
Refer to How to: Use the Composite Link for a code sample.
In addition to the above link types, you can create custom links inherited from the LinkBase class.