LinkBase.CreateDocument(Boolean) Method

Creates a document from the link, so it can be displayed or printed. Optionally, the document pages can be generated progressively and accessed as soon as they are created. Document creation is always synchronous and does not occur in a background thread.

Namespace: DevExpress.Xpf.Printing

Assembly: DevExpress.Xpf.Printing.v21.2.dll


public void CreateDocument(
    bool buildForInstantPreview


Name Type Description
buildForInstantPreview Boolean

true to enable accessing document pages progressively as they are created; otherwise false.


Use the CreateDocument method to generate a document for the current link.

When this link is exported (i.e., the LinkBase.ExportToHtml or any other export method is called for this link), the CreateDocument method is internally called with the false parameter, prior to the start of the exporting procedure. Once the document export has started, it will run until the resulting document is complete and cannot be interrupted or canceled in the process.


If the buildForInstantPreview parameter is set to true, document pages can be accessed progressively as they are created. In Print Preview, this enables you to start viewing the document as soon as its first page is ready. Remaining pages are progressively rendered in Print Preview.

Regardless of this parameter setting, a document will not be produced in a background thread. Document creation is not asynchronous, as a document is created using ticks from the DispatcherTimer class.

When this option is enabled, you can use the PrintingSystemBase.CreateDocumentException event to handle custom exceptions, which may occur during document creation. When an exception is handled (the ExceptionEventArgs.Handled property is set to true for it), the report creation process stops without displaying any errors in Print Preview.

Background document creation can be interrupted by calling the LinkBase.StopPageBuilding method.


This example demonstrates how to use SimpleLink to print data from a non-hierarchical datasource.

To do this, perform the following steps.

View Example

using System;
using System.Globalization;
using System.Windows;
using DevExpress.Xpf.Printing;
// ...
string[] data;

private void button1_Click(object sender, RoutedEventArgs e) {
    // Create an array of strings.
    data = CultureInfo.CurrentCulture.DateTimeFormat.DayNames;

    // Create a link and specify a template and detail count for it.
    SimpleLink link = new SimpleLink();
    link.DetailTemplate = (DataTemplate)Resources["dayNameTemplate"];
    link.DetailCount = data.Length;

    // Create a document.
    link.CreateDetail += new EventHandler<CreateAreaEventArgs>(link_CreateDetail);

    // Show a Print Preview window.
    PrintHelper.ShowPrintPreviewDialog(this, link);

void link_CreateDetail(object sender, CreateAreaEventArgs e) {
    e.Data = data[e.DetailIndex];
See Also