RichEditDocumentServer Class
A non-visual .NET library providing all the word processing functionality.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.RichEdit.v26.1.Core.dll
Declaration
[ComVisible(true)]
[DXLicenseDocsBasic]
public class RichEditDocumentServer :
IRichEditDocumentServer,
IBatchUpdateable,
IServiceContainer,
IServiceProvider,
IDisposable,
IInternalRichEditDocumentServerOwner,
IBasePrintable,
IPrintingTarget
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 topic for a full list of supported features: Overview of the Word Processing Document API Features.
Check the following topic to get started with the Word Processing Document API: Getting Started
Warning
The Office & PDF File API (Basic Edition), which included the Word Processing Document API and Excel Export API libraries, was discontinued on October 17, 2024.
If you purchased a DevExpress Universal, DXperience, WinForms, WPF, Office & PDF File API, Reporting, or ASP.NET subscription before October 17, 2024, the DevExpress Office & PDF File API (Basic Edition) will remain available to you.
If you are new to DevExpress and are interested in our Office & PDF File API, please refer to the following webpage for pricing/licensing information: DevExpress Office & PDF File API
Example
How to: Generate and Print a Document in Code
The following code snippet uses RichEditDocumentServer to create a new document, modify and print it.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
// Specify default formatting
wordProcessor.Document.DefaultParagraphProperties.Alignment = ParagraphAlignment.Center;
// Specify page settings
wordProcessor.Document.Sections[0].Page.Landscape = true;
wordProcessor.Document.Sections[0].Page.Height = DevExpress.Office.Utils.Units.InchesToDocumentsF(10.0f);
wordProcessor.Document.Sections[0].Page.Width = DevExpress.Office.Utils.Units.InchesToDocumentsF(4.5f);
// Add document content
wordProcessor.Document.AppendText("This content is created programmatically\n");
wordProcessor.Document.Paragraphs.Append();
// Create a table
Table _table = wordProcessor.Document.Tables.Create(wordProcessor.Document.Selection.Start, 8, 8, AutoFitBehaviorType.FixedColumnWidth);
_table.BeginUpdate();
_table.Borders.InsideHorizontalBorder.LineThickness = 1;
_table.Borders.InsideHorizontalBorder.LineStyle = BorderLineStyle.Double;
_table.Borders.InsideVerticalBorder.LineThickness = 1;
_table.Borders.InsideVerticalBorder.LineStyle = BorderLineStyle.Double;
_table.TableAlignment = TableRowAlignment.Center;
_table.ForEachCell((cell, rowIndex, columnIndex) =>
{
wordProcessor.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} is {2}",
rowIndex + 2, columnIndex + 2, (rowIndex + 2) * (columnIndex + 2)));
});
_table.EndUpdate();
// Print the document
PrinterSettings printerSettings = new PrinterSettings();
// Set the document pages to print:
printerSettings.FromPage = 2;
printerSettings.ToPage = 3;
// Specify the number of copies:
printerSettings.Copies = 2;
// Print the document:
wordProcessor.Print(printerSettings);
}