Skip to main content

How to: Merge several documents content into a single document

This example demonstrates how to merge several documents content into a single document and display the resulting content in ASPxRichEdit.

To merge documents, use the non-visual RichEditDocumentServer component.

Call the Open(String, DocumentFormat, Func<Stream>) method tTo open the resulting stream in ASPxRichEdit.

<dx:ASPxRichEdit ID="ASPxRichEdit1" runat="server" WorkDirectory="~\App_Data\WorkDirectory" />
using DevExpress.Web.Office;
using DevExpress.XtraRichEdit;

// ...
DocumentManager.CloseDocument("testID");
MemoryStream stream = new MemoryStream();
RichEditDocumentServer server = new RichEditDocumentServer();
server.LoadDocument(System.Web.HttpContext.Current.Server.MapPath("Doc 1.docx"), DocumentFormat.OpenXml);
server.Document.AppendDocumentContent(System.Web.HttpContext.Current.Server.MapPath("Doc 2.docx"), DocumentFormat.OpenXml);
server.SaveDocument(stream, DocumentFormat.OpenXml);
stream.Position = 0;
ASPxRichEdit1.Open("testID", DevExpress.XtraRichEdit.DocumentFormat.OpenXml, () => { return stream; });