A newer version of this page is available. Switch to the current version.

Getting Started

  • 2 minutes to read

This tutorial describes how to get started with the Word Processing Document API.

  1. Start Visual Studio and create a new project by selecting FILE | New | Project… in the main menu. In the invoked New Project dialog, select Console Application, specify the project name and location, and click OK.


  2. In the Solution Explorer, right-click the References node and select Add Reference… in the context menu.


  3. In the invoked Reference Manager dialog, add references to the following libraries.

    • System.Drawing.dll (to follow this example only)
    • DevExpress.Data.v18.2.dll
    • DevExpress.Office.v18.2.Core.dll
    • DevExpress.RichEdit.v18.2.Core.dll
    • DevExpress.Printing.v18.2.Core.dll
    • DevExpress.Pdf.v18.2.Core.dll
  4. Paste the code listed below in the Main method of the Program.cs file (or the Main procedure of the Module1.vb file for Visual Basic). This example creates and saves the Test.docx file, and opens it in the default application registered for this file type.

    static void Main(string[] args)
        string fileName = "Test.docx";
        using (DevExpress.XtraRichEdit.RichEditDocumentServer srv = 
            new DevExpress.XtraRichEdit.RichEditDocumentServer())
            DevExpress.XtraRichEdit.API.Native.Document doc = srv.Document;
            doc.AppendText("This document is generated by Word Processing Document API");
            DevExpress.XtraRichEdit.API.Native.CharacterProperties cp = doc.BeginUpdateCharacters(doc.Paragraphs[0].Range);
            cp.ForeColor = System.Drawing.Color.FromArgb(0x83, 0x92, 0x96);
            cp.Italic = true;
            DevExpress.XtraRichEdit.API.Native.ParagraphProperties pp = doc.BeginUpdateParagraphs(doc.Paragraphs[0].Range);
            pp.Alignment = DevExpress.XtraRichEdit.API.Native.ParagraphAlignment.Right;
            srv.SaveDocument(fileName, DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
  5. Run the project.

The following image demonstrates the file generated after executing the code above (the document is opened in Microsoft® Word®).