Merge two documents in the same page

Hello,

We are trying to merge two documents to the same page I am trying the example on the documentation:

https://help.syncfusion.com/file-formats/docio/word-document/merging-word-documents?cs-save-lang=1&cs-lang=csharp#merge-document-in-same-page


we are sending two SFDT objects to the Webservice:


public class SaveParameter
    {
      public string document { get; set; }
      public string documentToMerge { get; set; }
    }
 
 public string MergeDocuments([FromBody] SaveParameter data)
    {
      Stream sourceDocument = WordDocument.Save(data.documentToMerge, FormatType.Docx);
      Stream destinationDocument = WordDocument.Save(data.document, FormatType.Docx);

      using (WDocument document = new WDocument(sourceDocument, WFormatType.Docx))
      {

        WDocument newDocument = new WDocument(destinationDocument, WFormatType.Docx);
        document.Sections[0].BreakCode = Syncfusion.DocIO.DLS.SectionBreakCode.NoBreak;
        newDocument.ImportContent(document, Syncfusion.DocIO.DLS.ImportOptions.UseDestinationStyles);
        MemoryStream stream = new MemoryStream();
        newDocument.Save(stream, WFormatType.Docx);

        string json = ImportWordDocument(stream);
        return json;
      }
    }

private string ImportWordDocument(Stream stream)
    {
      string sfdtText = "";
      Syncfusion.EJ2.DocumentEditor.WordDocument document = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
      sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document);
      document.Dispose();
      return sfdtText;
    }

but still add a second page with the new document added.

1 Reply

SB Suriya Balamurugan Syncfusion Team May 5, 2022 11:17 AM UTC

Hi Lucas,

On further validating we found that the document has continuous section break.

Currently, Documenteditor doesn’t support continuous section break and will consider as next page section break.

We have already logged this as a feature request in our database. We don't have any immediate plans to implement this feature. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We will update you when this feature has been implemented.

You can track the status of feature from the below link:
https://www.syncfusion.com/feedback/5154/support-for-continuous-section-layout

Please let us know if you need any further assistance.

Regards,
Suriya Balamurugan.



Loader.
Up arrow icon