Aspose.Words.Examples.CSharp.Loading_Saving.Worker.InsertSectionBreaks C# (CSharp) Method

InsertSectionBreaks() private method

Inserts section breaks before the specified paragraphs.
private InsertSectionBreaks ( ArrayList topicStartParas ) : void
topicStartParas System.Collections.ArrayList
return void
        private void InsertSectionBreaks(ArrayList topicStartParas)
        {
            DocumentBuilder builder = new DocumentBuilder(mDoc);
            foreach (Paragraph para in topicStartParas)
            {
                Section section = para.ParentSection;

                // Insert section break if the paragraph is not at the beginning of a section already.
                if (para != section.Body.FirstParagraph)
                {
                    builder.MoveTo(para.FirstChild);
                    builder.InsertBreak(BreakType.SectionBreakNewPage);

                    // This is the paragraph that was inserted at the end of the now old section.
                    // We don't really need the extra paragraph, we just needed the section.
                    section.Body.LastParagraph.Remove();
                }
            }
        }