We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Importing document does not preserve section breaks

I have a problem with a NodeImporter class. When using ImportNode method, paragraphs that are keeping end of section info (para.IsEndOfSection) were not imported with this property. That makes final document without a sections from imported one.

What I would like to accomplish. There are two documents and I am importing one into another at Any Location of the first document (it is not bookmark). I would like to preserve sections structure (with all breaks) and header-footer nodes from source document.

I was looking for solution on following link .

Unfortunately it is not satisfying our case. I expect to have same behavior as when using AltChunk from OpenXml. Old logic merges HeaderFooter from source document into destination's target section and import's all body nodes. In case when source document has section breaks, these will be also added to destination document. HeaderFooters will follow the sections.

Here it the code snipped that we are using in old design.

BasePart parentPart = elementToInsertBefore.GetParentPart(this.document.MainDocumentPart);

if (parentPart != null)


AlternativeFormatImportPart inDocPart = parentPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML);

inDocPart.FeedData(File.Open(filenameToInsert, FileMode.Open));<o:p></o:p>

AltChunk altChunk = new AltChunk(new WordProcessing.AltChunk());

altChunk.Id = parentPart.Part.GetIdOfPart(inDocPart);

Paragraph parentParagraph = elementToInsertBefore.getInsertFileParagraph();

if (parentParagraph != null)





How I can accomplish this ?

Thank you

Hi Rastko,

Thanks for your inquiry. In your case, we suggest you please use DocumentBuilder.InsertDocument method to insert content of the document into the current position of DocumentBuilder's cursor. This method mimics the MS Word behavior, as if CTRL+'A' (select all content) was pressed, then CTRL+'C' (copy selected into the buffer) inside one document and then CTRL+'V' (insert content from the buffer) inside another document.

Please read following documentation link. The method preserve the section breaks while inserting the contents. Hope this helps you.

Inserting content of the Document