How to: Merge several documents content into a single document

  • 3 minutes to read

In some scenarios, it's necessary to combine several documents content (for example, from documents stored in a database) into a single document and display the resulting content in ASPxRichEdit.

This example demonstrates how to merge several documents content by using the RichEditDocumentServer component, our non-visual document processing engine.

To open the resulting stream containing the document's content in ASPxRichEdit, the Open(String, DocumentFormat, Func<Stream>) method is used.

View Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="DevExpress.Web.ASPxRichEdit.v__, Version=__, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxRichEdit" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v__, Version=__, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 <script>
  function OnClick(s, e) {
   re.PerformCallback();
  }
 </script>
</head>
<body>
    <form id="form1" runat="server">
     <table>
      <tr>
       <td>
        Document 1:
        <dx:ASPxRichEdit ID="ASPxRichEdit2" runat="server" Width="500" Height="350" ReadOnly="true" WorkDirectory="~\App_Data\WorkDirectory">
         <Settings>
          <Behavior CreateNew="Hidden" Save="Hidden" Open="Hidden" SaveAs="Hidden" />
         </Settings>
        </dx:ASPxRichEdit>
       </td>
       <td>
         Document 2:
        <dx:ASPxRichEdit ID="ASPxRichEdit3" runat="server" Width="500" Height="350" ReadOnly="true" WorkDirectory="~\App_Data\WorkDirectory">
         <Settings>
          <Behavior CreateNew="Hidden" Save="Hidden" Open="Hidden" SaveAs="Hidden" />
         </Settings>
        </dx:ASPxRichEdit>
       </td>
      </tr>
     </table>
     <br />
     <dx:ASPxButton ID="ASPxButton1" runat="server" Text="Merge documents content" AutoPostBack="false">
      <ClientSideEvents Click="OnClick" />
     </dx:ASPxButton>
     <br />
     <br />
     <dx:ASPxRichEdit ID="ASPxRichEdit1" ClientInstanceName="re" runat="server" WorkDirectory="~\App_Data\WorkDirectory" OnCallback="ASPxRichEdit1_Callback">
      <Settings>
       <Behavior CreateNew="Hidden" Save="Hidden" Open="Hidden" SaveAs="Hidden" />
      </Settings>
     </dx:ASPxRichEdit>

    </form>
</body>
</html>