The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

RichEditDocumentServer Class

A non-visual .NET library providing all the word processing functionality.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.RichEdit.v19.1.Core.dll

Declaration

[ComVisible(true)]
public class RichEditDocumentServer :
    IRichEditDocumentServer,
    IBatchUpdateable,
    IServiceContainer,
    IServiceProvider,
    IDisposable,
    IInternalRichEditDocumentServerOwner,
    IPrintable,
    IBasePrintable
<ComVisible(True)>
Public Class RichEditDocumentServer
    Implements IRichEditDocumentServer,
               IBatchUpdateable,
               IServiceContainer,
               IServiceProvider,
               IDisposable,
               IInternalRichEditDocumentServerOwner,
               IPrintable,
               IBasePrintable
[ComVisible(true)]
public class RichEditDocumentServer :
    IRichEditDocumentServer,
    IBatchUpdateable,
    IServiceContainer,
    IServiceProvider,
    IDisposable,
    IInternalRichEditDocumentServerOwner,
    IPrintable,
    IBasePrintable
<ComVisible(True)>
Public Class RichEditDocumentServer
    Implements IRichEditDocumentServer,
               IBatchUpdateable,
               IServiceContainer,
               IServiceProvider,
               IDisposable,
               IInternalRichEditDocumentServerOwner,
               IPrintable,
               IBasePrintable

Remarks

Use the RichEditDocumentServer component to modify a document without user interaction. It enables you to automate such common tasks as format conversion, character and paragraph formatting, table operations, adjusting page layout options and mail merging. Refer to the Word Processing Document API topic for a full list of supported features.

Check the Getting Started topic to get started with the Word Processing Document API.

Note

The Word Processing Document API does not require the DevExpress.Docs.19.1.dll assembly for operation and distribution. A separate license is not required.

Examples

The following code snippet uses RichEditDocumentServer to create a new document, modify and print it.

Note

The code sample uses the PrintingSystem class. Make sure that the DevExpress.XtraPrinting.v19.1.dll assembly is added to your project.

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraPrinting;

RichEditDocumentServer richServer = new RichEditDocumentServer();
// Specify default formatting
richServer.Document.DefaultParagraphProperties.Alignment = ParagraphAlignment.Center;
// Specify page settings
richServer.Document.Sections[0].Page.Landscape = true;
richServer.Document.Sections[0].Page.Height = DevExpress.Office.Utils.Units.InchesToDocumentsF(10.0f);
richServer.Document.Sections[0].Page.Width = DevExpress.Office.Utils.Units.InchesToDocumentsF(4.5f);
// Add document content
richServer.Document.AppendText("This content is created programmatically\n");
richServer.Document.AppendParagraph();

//Create a table
Table _table = richServer.Document.Tables.Create(richServer.Document.Selection.Start, 8, 8, AutoFitBehaviorType.FixedColumnWidth);
_table.BeginUpdate();
_table.Borders.InsideHorizontalBorder.LineThickness = 1;
_table.Borders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.Double;
_table.Borders.InsideVerticalBorder.LineThickness = 1;
_table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.Double;
_table.TableAlignment = TableRowAlignment.Center;

_table.ForEachCell((cell, rowIndex, columnIndex) =>
{
    richServer.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} is {2}",
        rowIndex + 2, columnIndex + 2, (rowIndex + 2) * (columnIndex + 2)));
});
_table.EndUpdate();

// Invoke the Print Preview dialog
using (PrintingSystem printingSystem = new PrintingSystem()) 
{
    using (PrintableComponentLink link = new PrintableComponentLink(printingSystem))
    {
        link.Component = richServer;
        link.CreateDocument();
        link.ShowPreviewDialog();
    }
}

Inheritance

Object
RichEditDocumentServer
See Also