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));
AltChunk altChunk = new AltChunk(new WordProcessing.AltChunk());
altChunk.Id = parentPart.Part.GetIdOfPart(inDocPart);
Paragraph parentParagraph = elementToInsertBefore.getInsertFileParagraph();
if (parentParagraph != null)
{
parentParagraph.InsertBefore(altChunk);
}
}
How I can accomplish this ?
Thank you