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.