[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Collapse]Form Layout Managers
    Side Panel
   [Collapse]Layout and Data Layout Controls
    [Expand]Product Information
    [Expand]Getting Started
    [Expand]Layout Control
    [Expand]Data Layout Control
    [Expand]Layout Items
    [Expand]Layout Groups
    [Expand]Tabbed Groups
    [Expand]Other Layout Elements
    [Expand]Design-Time and Runtime Customization
    [Expand]Size and Alignment
     Flow Layout
     Table Layout
     Focus Management
    [Expand]Appearance and Look and Feel
    [Collapse]Miscellaneous
      Save and Restore Layout
      Hit Information
      Printing and Export
    [Expand]Examples
    [Expand]Member Tables
   [Expand]Tabbed MDI Manager
    Tab Control
   [Expand]Wizard Control
    Workspace Manager
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Printing and Export

This document shows how you can export, print and display a print preview for the Layout Control.

Expanded Printing/Export Basics

The Layout Control provides methods to preview, print and export its contents. These methods delegate the print/export actions to the XtraPrinting Library. Thus, the print/export functionality is not available if this library cannot be found (see LayoutControl.IsPrintingAvailable).

To preview and print the Layout Control's contents, use the following methods.

Member Description
LayoutControl.ShowPrintPreview Opens the Print Preview window for the LayoutControl with a Bars UI.
LayoutControl.ShowRibbonPrintPreview Displays the Print Preview window with a Ribbon UI.
LayoutControl.Print Prints the LayoutControl.

Using the Preview window, an end-user is able to customize the page settings (the page format, size, orientation, etc.), change a background color, export the Layout Control to various formats (PDF, HTML, etc.), etc.

The following methods allow you to export the Layout Control to various formats.

Member Description
LayoutControl.ExportToHtml Exports the controls displayed within the LayoutControl to a stream in HTML format using the specified character encoding, with the specified title. The output file can be compressed (secondary characters e.g. spaces are removed) if required.
LayoutControl.ExportToMht Exports the controls displayed within the LayoutControl to a stream in MHT format using the specified character encoding, with the specified title. The output file can be compressed (secondary characters e.g. spaces are removed) if required.
LayoutControl.ExportToPdf Exports the controls displayed within the LayoutControl to a stream in PDF format.
LayoutControl.ExportToRtf Exports the controls displayed within the LayoutControl to a file in RTF format.
LayoutControl.ExportToText Exports the controls displayed within the LayoutControl to a stream in TXT format using the specified separator string and quotation settings.
LayoutControl.ExportToXls Exports the controls displayed within the LayoutControl to a stream in XLS format using the specified formatting settings.
LayoutControl.ExportToXlsx Exports data to the specified stream in XLSX (MS Excel 2007) format using the specified options.
Note

Custom painting, alpha blending and color gradient features are not supported when the Layout Control is printed/exported.

Example

The following example demonstrates how to print a LayoutControl and show its Print Preivew. The LayoutControl.Print and LayoutControl.ShowPrintPreview methods are called respectively.

Expanded Default Print and Export Mode

By default, the Layout Control follows the "Flow layout" approach when arranging items in the print/export document, not the WYSIWYG approach

According to the "Flow layout" principle, layout items are arranged back-to-back, filling the page area in the optimal way. The flow of items wraps at the page's right edge. So, if there is insufficient space in a row to accommodate an item, this item is carried over to the following row.

Items in the print/export document can occupy less space compared to their original size. For instance, a layout item with a text editor is shrunk to display the editor's text in its entirety.

Specific compound controls (e.g., GridControl, ChartControl, SpreadsheetControl, TreeList, etc.) implement the IPrintable interface, which maintains high-quality printing/export using the DevExpress XtraPrinting Library.

When you print or export a Layout Control that contains any of these controls, the Layout Control invokes high-quality printing/export for these controls using the DevExpress Printing Library (in the old print/export mode, these controls are printed/exported as images). The IPrintable controls are printed starting from the left edge of a page, occupying the entire page width. Even if a control's contents are partially visible on the form and vertical scrollbars are enabled, the height of the control is increased in the print/export document to print the control's contents in their entirety.

Multiple print options provided by IPrintable controls are taken into account when the Layout Control is printed/exported.

The image below shows a print preview for a Layout Control containing several text editors and a Grid Control.

Expanded Old Printing and Export (WYSIWYG)

To enable the legacy print and export mode, which follows the WYSIWYG approach, set the OptionsPrintControl.OldPrinting property to true.

In this mode, the Layout Control is printed/exported as is, keeping the arrangement of items. By default, the Layout Control is scaled to the page width. This functionality can be disabled with the OptionsPrintControl.AllowFitToPage property.

The following image demonstrates a print preview of a Layout Control containing several text editors and a Data Grid.

  • Controls that are not derived from the BaseEdit class are printed as images. Their printed versions are graphical copies of display versions. For instance, if a Grid Control displays scrollbars on the form, the scrollbars will be included in the print/export output as well.
  • Text editors that are derived from the BaseEdit class are represented by their values. No border is painted when printed. Values of editors are printed as text.
  • Graphical editors that are derived from the BaseEdit class are printed as images.

Expanded Printing/Export Options

The Layout Control provides properties to customize print- and export-aware settings.

Expanded Printing/Export Appearance

By default, a printed Layout Control uses the same appearance settings as when it is displayed on screen.

In default print/export mode, you can customize the print/export appearance settings as follows:

Note

Print appearance settings are not supported if the OptionsPrintControl.OldPrinting property is set to true.

Expanded See Also

Is this topic helpful?​​​​​​​