Export to Image
- 3 minutes to read
This document details the exporting of a document to Image.
The options that can be specified for a document exported to an image file are stored in the ImageExportOptions class, and can be accessed via a report’s ExportOptions.Image property.
Numerous image formats are supported, specified via the ImageExportOptions.Format property. They are listed below.
- BMP;
- EMF;
- WMF;
- GIF;
- JPEG;
- PNG;
- TIFF.
Among these options, the ImageExportOptions.ExportMode property determines the way in which a document is exported to Image. For instance, it may be exported to a single file (with a single page header at the beginning and a single page footer at the end). Or it may be exported page-by-page to either a single file or different files.
To specify the quality of text rendering in images (especially in images having small dpi values and a transparent background), use the ImageExportOptions.TextRenderingMode property.
Example: How to Export a Report to Image Format
The following example demonstrates how to export a report to image format:
using System.Diagnostics;
using System.Drawing.Imaging;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
namespace ExportToImageCS {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
// A path to export a report.
string reportPath = "c:\\Test.png";
// Create a report instance.
XtraReport1 report = new XtraReport1();
// Get its Image export options.
ImageExportOptions imageOptions = report.ExportOptions.Image;
// Set Image-specific export options.
imageOptions.Format = ImageFormat.Png;
// Export the report to Image.
report.ExportToImage(reportPath);
// Show the result.
StartProcess(reportPath);
}
// Use this method if you want to automaically open
// the created Image file in the default program.
public void StartProcess(string path) {
Process process = new Process();
try {
process.StartInfo.FileName = path;
process.Start();
process.WaitForInputIdle();
}
catch { }
}
}
}