StructuredDocumentTagRange-Section break keep remains at the end of the tag

Hi Team,

We have a StructuredDocumentTagRange inside our template and that tag contains a section break at the end of the tag.

We are identifying the RangeStart, RangeEnd and adding a condition to remove SDTRange but the section break keep remains in generated document as is.

Code Snippet:

Can someone please let us know how we can remove last section break?

Template_SDTRangeTagWithSectionBreak

Template_DocumentXML

@RajmalConga Could you please attach your input and expected output documents? Unfortunately, it is difficult to analyze the issue using screenshots without real documents.

Hi @alexey.noskov,

We have input document in a different format which we are transforming to a Aspose linq engine standard format (this time we have issue) and generating document.
I have attached the required docs, PFA.

Let me know if anything else is required.ExpectedOutputDocument.docx (41.0 KB)
GeneratedOutputDocument.docx (39.8 KB)
InputTemplateDocument.docx (49.1 KB)

Thanks.

@RajmalConga To remove section break you need to concatenate sections content and remove redundant section. For example see the following code:

Document doc = new Document(@"C:\Temp\InputTemplateDocument.docx");

// Get StructuredDocumentTagRangeEnd 
StructuredDocumentTagRangeEnd end = (StructuredDocumentTagRangeEnd)doc.GetChild(NodeType.StructuredDocumentTagRangeEnd, 0, true);

// Check if StructuredDocumentTagRangeEnd is the last node in the section.
Section parentSection = (Section)end.GetAncestor(NodeType.Section);
if (parentSection.Body.LastChild == end)
{
    // Copy conttent of the section with StructuredDocumentTagRangeEnd to the next section.
    if (parentSection.NextSibling != null)
    {
        Section nextSection = (Section)parentSection.NextSibling;
        nextSection.PrependContent(parentSection);
        parentSection.Remove();
    }
}

doc.Save(@"C:\Temp\out.docx");