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

Free Support Forum - aspose.com

Page break is adding a blank paragraph to the top of my document

I have an aspose document that I am building and I need to add a page break. I use the code below to append a page break to my exsisting document mobjMainAsposeDoc. The blank page will be inserted but when I go to insert (append) my next document the appended text will be one line down from the top of the page. How do I postion myself at the top of the page so that my next Appenddocument will actually start at the top? I am using Aspose Words 6.4

I have tried doing adding this line after the sectionStart.NewPage lobjDocEmptyPage.Range.Delete but this will remove the page break.

Dim lobjDocEmptyPage As Aspose.Words.Document = New Aspose.Words.Document

For Each lSection As Aspose.Words.Section In lobjDocEmptyPage.Sections

If mbPrintLegal = True Then

lSection.PageSetup.PaperSize = Aspose.Words.PaperSize.Legal


lSection.PageSetup.PaperSize = Aspose.Words.PaperSize.Letter

End If


lobjDocEmptyPage.FirstSection.PageSetup.SectionStart = SectionStart.NewPage

mobjMainAsposeDoc.AppendDocument(lobjDocEmptyPage, ImportFormatMode.UseDestinationStyles)


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try inserting section break instead of page break. Please see the following line of code:


Hope this helps.

Best regards.

Tried SectionBreakNewPage and I still get the blank line. It appears that the blank line is coming from the Section break(continuous) that appears after the Section Break(Next Page).

Also please advise as to why I get a "Object reference not set to an instance of an object." error when I try and perform an UpdatePageLayout on the attached document. The attached document also demonstrates that blank line issue.

Dim lobjLineDocTemp As New Aspose.Words.Document("c:\PageCount47.doc")



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Yes, you are right, blank line is coming from the Section break at the beginning of the second page.

I think as a workaround you can set ParagraphFormat.PageBreakBefore option. For example see the following code:

Document doc = new Document(@"Test001\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);


builder.CurrentParagraph.ParagraphFormat.PageBreakBefore = true;


Regarding the problem with UpdatePageLayout, I cannot reproduce this problem on my side. I use the latest version of Aspose.Words for testing. You can download it from here:


Best regards.