Wiki

Clone wiki

Aspose for OpenXML / Keeping the content from Split

It keeps the formatting of destination document as it is instead of following the source document contents.

 Document dstDoc = new Document("src.doc");
            Document srcDoc = new Document("srcDocument.doc");

            // Set the source document to appear straight after the destination document's content.
            srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;

            // Iterate through all sections in the source document.
            foreach (Paragraph para in srcDoc.GetChildNodes(NodeType.Paragraph, true))
            {
                para.ParagraphFormat.KeepWithNext = true;
            }

            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
            dstDoc.Save("JoiningDocumentByKeepingContentfromSplit.doc");

Download

Updated