RemovePageBreaks.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Linq
Imports GrapeCity.Documents.Word

Public Class RemovePageBreaks
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        doc.Load(Path.Combine("Resources", "WordDocs", "breaks.docx"))
        For Each brr In doc.Body.Texts.Where(Function(txt) TypeOf txt Is Break AndAlso DirectCast(txt, Break).Type = BreakType.Page).ToArray()
            brr.Delete()
        Next
        Dim sec = doc.Body.Sections.First
        Do While sec.Next IsNot Nothing
            If sec.PageSetup.SectionStart <> SectionStart.Continuous Then
                sec.PageSetup.SectionStart = SectionStart.Continuous
            End If
            sec = sec.Next
        Loop
        Return doc
    End Function
End Class