Skip to main content

How to: Save a Document as a Series of Images

  • 2 minutes to read

This example shows how to use the DXPrinting library to save a document as a series of images. The API from the table below allows you to accomplish this task.

Member Description
PrintableComponentLinkBase Initializes a new instance of the PrintableComponentLinkBase class with the default settings.
PrintableComponentLinkBase.Component Gets or sets a IPrintable user implementation printed via the current link.
PrintableComponentLinkBase.CreateDocument Creates a report using the current PrintingSystem.
ImageExportOptions Initializes a new instance of the ImageExportOptions class with the default settings.
ImageExportOptions.ExportMode Specifies whether document pages are exported to a single or multiple images.
ImageExportOptions.Format Specifies the image format for exporting a document.
ImageExportOptions.Resolution Specifies the image resolution (in DPI).
ImageExportOptions.PageRange Specifies the range of pages to be exported.
PrintingSystemBase.ExportToImage Exports a document to an image with the specified format and sends it to a stream.

The following code snippet exports the document to a series of PNG images with the specified options.

View Example

using DevExpress.XtraPrinting;
using DevExpress.XtraPrintingLinks;
using DevExpress.XtraRichEdit;

PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
pcl.Component = ((IRichEditControl)richEditControl1).InnerControl;
pcl.CreateDocument(false);
ImageExportOptions imgOptions = new ImageExportOptions();
imgOptions.ExportMode = ImageExportMode.DifferentFiles;
imgOptions.Format = DXImageFormat.Png;
imgOptions.Resolution = 150;
imgOptions.PageRange = "1,3-5";
pcl.ExportToImage("export.png", imgOptions);