Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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 the specified stream as an image. Use options to specify an image format.

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);