- 2 minutes to read
This topic provides an overview of the various approaches to create documents using printing links.
Among the different approaches to rendering documents from a component’s content, the easiest is to use a unified printing procedure, which is a printing link that transforms a control’s data into bricks of appropriate types, and arranges them into a printing document. You can use a printing link to print a non-visual component (such as a dataset) as well.
To print an object using a link at design time within Visual Studio, do the following.
Drop the DocumentViewer component from the DX.21.1: Reporting Toolbox tab onto the main form of your application.
To add a printing system to the print preview, select the DocumentViewer control and click its smart tag. Next, expand the Document Source property drop-down list, and select the PrintingSystem item in the Standard Sources category.
This will add a new printing system to the application and assign it to the DocumentViewer.DocumentSource property of the document viewer.
To add a printing link of the required type to the PrintingSystem.Links collection, select the printing system in the component tray, click its smart tag, and click the ellipsis button for the Links property in the invoked actions list.
In the invoked Link Collection Editor, click Add and select the required link type from the drop-down list.
For example, to print a DevExpress control (such as GridControl, PivotGridControl or RichEditControl), select PrintableComponentLink. To create a single document from multiple individual controls, you can combine multiple links into a CompositeLink. To learn about the available link types, see Document Creation Approaches.
A property for associating an object with a link depends on the link type (e.g., the DataGridLink exposes the DataGridLinkBase.DataGrid property, and the PrintableComponentLinkBase exposes the PrintableComponentLinkBase.Component property).
The printing system will then render a component’s content to a document that is ready to preview, print and/or export.
To insert printing bricks into an existing document, use the corresponding methods of the BrickGraphics class. The Link will automatically associate the necessary brick types, so the BrickGraphics class creates compatible bricks and adds them to the document. For more information, refer to Brick Graphics.