[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Collapse]Office File API
  Demo Application
  Redistribution and Deployment
 [Expand]Spreadsheet Document API
 [Collapse]Word Processing Document API
   Getting Started
  [Expand]WordProcessing Document
  [Collapse]Merge and Split Documents
    Merge Documents
    Split Documents
   Import and Export
  [Expand]Fields
   Text Formatting
  [Expand]Mail Merge
   Printing
   Export to PDF
   Document Protection
   HTML Tag Support
  [Expand]Examples
 [Expand]PDF Document API
 [Expand]Excel Export Library
 [Expand]Snap Report API
 [Expand]Zip Compression and Archive API
 [Expand]Barcode Generation API
 [Expand]Unit Conversion API
 [Expand]API Reference
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Merge Documents

This topic describes how to use the RichEditDocumentServer to merge documents and keep document formatting.

Expanded Merge Documents

  1. Load documents to be merged in separate RichEditDocumentServer instances.
  2. Insert the content of one server into another using one of the following methods:

  3. Call the IRichEditDocumentServer.SaveDocument method to save the resulting document.

Expanded Merge Documents into a PDF File

Call the RichEditDocumentServer.ExportToPdf method to export the result to a PDF file. You can also export all documents to separate PDF files and merge them using the PDF Document API. Refer to the How to: Merge Documents into a Single PDF File topic for more information.

Expanded Keep Document Formatting

Direct Formatting and Styles

Pass one of InsertOptions enumeration members to SubDocument.AppendDocumentContent or SubDocument.InsertDocumentContent method as an insertOptions parameter to manage how the formatting is applied to the inserted content. The table below shows how formatting is applied depending on the selected value:

Enumeration Value

Direct Formatting

Styles (character, paragraph, table)

Non-textual objects (tables, floating objects, comments, etc.)

Tabs

InsertOptions.KeepSourceFormatting

The inserted text retains its formatting.

New styles (styles that don't exist in the target document) are copied. If character or paragraph style conflict occurs, all inserted style's properties are applied as direct formatting, but the style itself is not transferred. Destination document's styles with default settings are substituted with inserted styles of the same name. Conflicted table and numbering list styles are copied to the document. The style name is a combination of conflicted styles' names (e.g., Normal1 and Normal1 are combined into_Normal11_).

Non-textual elements are retained.

All page properties are retained.

InsertOptions.KeepTextOnly

The inserted text loses its formatting and takes on direct formatting applied to the target text range. Numbering lists are converted to simple text.

All inserted styles are not retained.

Floating objects, shapes and comments are discarded. Tables are converted into a series of paragraphs.

Tabs are lost.

InsertOptions.MergeFormatting

The inserted text retains the following character properties:

Other character properties and all paragraph properties are ignored.

Inserted style's character properties are applied as direct, but the style itself is not copied to the target document. Style paragraph properties are ignored. Table styles are not retained. Numbering list styles are transferred to the target document.

Non-textual elements are retained.

Tabs are ignored.

InsertOptions.UseDestinationStyles

The inserted text keeps its format options.

New styles (styles that don't exist in the target document) are copied. If style conflict occurs, the inserted content's styles are ignored. Destination document's styles with default settings are substituted with inserted styles of the same name.

Non-textual elements are retained.

All page properties are retained.

Note

The RichEditDocumentServer does not currently support themes. When merging documents with themes, the result may lose theme-related formatting.

Is this topic helpful?​​​​​​​