Word Processing Document API (New)
- 5 minutes to read
The Word Processing Document API is a cross-platform .NET library in the DevExpress Office & PDF File API for .NET suite that allows you to create, load, modify, and save Microsoft Word documents in code. You can use this library in desktop, web, and cloud applications (for example, Windows Forms, WPF, ASP.NET Core, and Blazor applications).
Important
The Word Processing Document API library is currently available as a Community Technology Preview (CTP). Do not use this pre-release library in mission-critical applications. Try the library and share your feedback to help us make final adjustments before the official release. To start a conversation, submit a ticket through the DevExpress Support Center.
The library exposes a strongly typed object model. The WordDocument class defines the root object. The main objects form the following hierarchy:
WordDocument
├─ Body
│ ├─ Paragraph
│ │ └─ InlineElements (text fragments, breaks, fields, hyperlinks, and shapes)
│ └─ Table
│ └─ Rows
│ └─ TableRow
│ └─ Cells
│ └─ TableCell
├─ Sections
│ └─ Section
│ ├─ Headers, Footers
│ └─ Page, Margins, Columns, PageNumbering
├─ ParagraphStyles, CharacterStyles, TableStyles, NumberingLists, Theme
├─ Bookmarks, Comments, Revisions, RangePermissions
└─ DocumentProperties
Why Migrate from the Previous Word Processing Document API?
The Word Processing Document API implements a strongly typed object model. This model allows you to access and modify paragraphs, text, tables, lists, sections, headers and footers, fields, hyperlinks, shapes, charts, comments, and revisions.
Compared to the previous Word Processing Document API, the new object model includes the following enhancements:
- Object Model That Mirrors the Document Structure
- Word Processing Document API objects correspond to elements of Word documents. The WordDocument.Body property gets the main document content (paragraphs and tables). The Paragraph.InlineElements collection contains text fragments, breaks, fields, hyperlinks, and shapes. You can add, insert, and remove these objects in code.
- Formatting Settings in Document Elements
- Each document element contains its own formatting settings. Use properties such as TextFragment.CharacterProperties, Paragraph.Properties, and Table.Properties to format text, paragraphs, and tables. You do not need to specify a document range to format content.
- Shared Office Object Model
- Chart content and document themes (WordDocument.Theme) use types from the
DevExpress.Docs.Officenamespace. The Spreadsheet Document API and Presentation API use the same types for charts and themes in workbooks and presentations.
Both libraries are available in v26.2.
| Word Processing Document API | Previous Word Processing Document API | |
|---|---|---|
| NuGet package | DevExpress.Docs.Word | DevExpress.Document.Processor |
| Namespace | DevExpress.Docs.Word |
DevExpress.XtraRichEdit, DevExpress.XtraRichEdit.API.Native |
| Main class | WordDocument | RichEditDocumentServer |
Important
Previous and new Word Processing Document API libraries contain classes with the same names (for example, Paragraph, Table, and Section). Do not combine types from DevExpress.XtraRichEdit.API.Native and DevExpress.Docs.Word namespaces in the same code.
Supported File Formats
The Word Processing Document API can load and save documents in the following formats:
- DOCX, DOCM, DOC
- DOTX, DOTM, DOT
- RTF, ODT
- HTML, MHT, EPUB
- TXT
- WordML, Flat OPC
You can also export documents to PDF.
Refer to the following help topics for additional information:
Prerequisites
The Word Processing Document API supports the following platforms, environments, and frameworks:
- Windows, Linux, macOS
- Azure, AWS, Docker
- .NET 10+, .NET Framework 4.6.2+
Add the DevExpress.Docs.Word NuGet package to your project:
dotnet add package DevExpress.Docs.Word
If a .NET Framework application does not use NuGet packages, add references to DevExpress assemblies. The Get Started tutorial lists the required assemblies.
Important
You need a license for the DevExpress Office & PDF File API Subscription or DevExpress Universal Subscription to use this library in production code.
Refer to the following help topics for additional information:
Get Started
Refer to the following tutorial to create your first Word Processing Document API application:
Features
- Documents
Create, load, and save documents, convert documents between formats, and specify document properties.
- Paragraphs, Text, and Lists
Add, modify, and remove paragraphs and text, insert line, page, and column breaks, and create bulleted, numbered, and multilevel lists.
- Tables
Create tables, add and remove rows and cells, merge and split cells, format tables, and apply table styles.
- Sections, Headers, and Footers
Divide a document into sections, specify page layout settings, and add headers and footers with page numbers.
- Fields, Hyperlinks, and Bookmarks
Insert and update fields, add hyperlinks, and mark document positions with bookmarks.
- Shapes, Pictures, and Charts
Add shapes and pictures to documents. Create standard charts and charts of types introduced in Microsoft Word 2016 (for example, waterfall, funnel, or treemap charts).
- Formatting and Styles
Apply character and paragraph formatting settings directly, create and apply paragraph, character, and table styles, and apply document theme colors and fonts.
- Comments and Revisions
Add comments and replies, track changes, and accept or reject revisions.
- Mail Merge
Merge data from lists, data tables, and data sets into document templates. Generate letters and master-detail reports, and save each record to a separate document.
- Document Security
Encrypt and protect documents, specify editable ranges, limit resource consumption during load operations, and remove unsafe content.
- Export to PDF
Export all or specific document pages to PDF and generate PDF/A and PDF/UA documents.
- Extract Document Content
Retrieve text from a document, a document range, or individual document elements.