Skip to main content
All docs
V25.1
  • RichEditDocumentServerExtensions.ExportToImage(Document, RichEditImageExportOptions) Method

    Exports a document to a list of images. Allows you to specify export options.

    Namespace: DevExpress.XtraRichEdit

    Assembly: DevExpress.Docs.v25.1.dll

    NuGet Package: DevExpress.Document.Processor

    Declaration

    public static IReadOnlyList<Stream> ExportToImage(
        this Document document,
        RichEditImageExportOptions options
    )

    Parameters

    Name Type Description
    document Document

    A document to export.

    options RichEditImageExportOptions

    An object that contains image export options.

    Returns

    Type Description
    IReadOnlyList<Stream>

    A list of stream objects. Each object contains a separate document page converted to an image.

    Remarks

    Example

    The following code sample exports first three document pages to images in JPEG format:

    using DevExpress.XtraRichEdit.Export.Image;
    using DevExpress.XtraRichEdit;
    using DevExpress.Drawing;
    
    using RichEditDocumentServer wordProcessor = new RichEditDocumentServer();
    wordProcessor.LoadDocument(@"C:\Documents\Alice.docx");
    var options = new RichEditImageExportOptions();
    options.Format = DXImageFormat.Jpeg;
    options.PageRange = "1-3";
    var streamList = wordProcessor.Document.ExportToImage(options);
    int i = 1;
    foreach (var stream in streamList) {
        var newFileName = Path.GetFileNameWithoutExtension("ExportedPage.jpeg") + i + Path.GetExtension("ExportedPage.jpeg");
        StreamToFile(stream, newFileName);
        i++;
        stream.Dispose();
    }
    static void StreamToFile(Stream stream, string filePath)
    {
        using (var fileStream = File.Create(filePath))
        {
            stream.Seek(0, SeekOrigin.Begin);
            stream.CopyTo(fileStream);
        }
    }
    
    See Also