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

Free Support Forum - aspose.com

Blank Page

I am storing data in tabular format in word doc using Aspose.word 15.12.0.0 version.


But there is problem with builder.End table as it moves the cursor to next row due to which I am getting blank page with headers (as i have to print the same headers on all the pages so i have set pageSetup.DifferentFirstPageHeaderFooter = False) in the end.

Sample code given below for your reference:

Dim doc As Document = New Document

Dim builder As DocumentBuilder = New DocumentBuilder(doc)


Dim currentSection As Section = builder.CurrentSection
Dim pageSetup As PageSetup = currentSection.PageSetup

pageSetup.DifferentFirstPageHeaderFooter = False
'pageSetup.DifferentFirstPageHeaderFooter = True

’ — Create header for the first page. —
pageSetup.HeaderDistance = 20
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst)
'builder.ParagraphFormat.Alignment = ParagraphAlignment.Center
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary)
’ Set font properties for header text.
builder.Font.Name = “Arial”
builder.Font.Bold = True
builder.Font.Size = 14
’ Specify header title for the first page.

builder.StartTable()
builder.InsertCell()
builder.Write(“Aspose.Words Header/Footer Creation Primer - Title Page.”)
builder.EndRow()
builder.EndTable()

’ Create header for pages other than first. —

'pageSetup.HeaderDistance = 20
'builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary)



builder.MoveToSection(0)
builder.StartTable()

builder.CellFormat.Width = 100.0

builder.InsertCell()

builder.Writeln(“Row 1, Cell 1”)

builder.InsertCell()

builder.Writeln(“If the source document has multiple sections already all using the same headers and footers then they will If the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they will all most likely be linked to the headers and footers of the previous section. This will mean after the headers and footers of the first section are linked to the previous section these sections will also automat In some cases if your source document uses different headers in multiple sections you may need to call the HeaderFooterCollection.LinkToPrevious m”)


builder.EndRow()

builder.InsertCell()

builder.Writeln(“Row 2, Cell 1”)

builder.InsertCell()

builder.Writeln(“If t footers then theyple sections already\sacument has multiple sections already all using ers dhsjkdhshdkshdkjshdsdkhsjkdjdbjsdbjsdhjsbdhsbbfdhfbmdfhbsdnhsvdvsndsgdkdjfbjdfkjdfkdk footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using ers dhsjkdhshdkshdkjshdsdkhsjkdjdbjsdbjsdhjsbdhsbbfdhfbmdfhbsdnhsvdvsndsgdkdjfbjdfkjdfkdk footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using ers dhsjkdhshdkshdkjshdsdkhsjkdjdbjsdbjsdhjsbdhsbbfdhfbmdfhbsdnhsvdvsndsgdkdjfbjdfkjdfkdk footers then theyers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using ers dhsjkdhshdkshdkjshdsdkhsjkdjdbjsdbjsdhjsbdhsbbfdhfbmdfhbsdnhsvdvsndsgdkdjfbjdfkjdfkdk footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sectionsthe source document has multiple sections already all using the same headers and footers then they willIf the source document has multiple sections already all using the same headers and footers then they will all most likely be linked to the headers and footers of the previous sectionm”)

builder.EndRow()

builder.EndTable()

builder.MoveToDocumentEnd()

doc.Save(“C:\Users\xxx\Desktop\doc\result.doc”)




Please suggest how can i remove extra/blank page from the end.
Hi Girish,

Thanks for your inquiry. Please note that MS Word document is flow document and pages and lines are created by Microsoft Word on the fly. Aspose.Words mimics the same behavior as MS Word does. If you create the same document using MS Word, you will get the same output.

Please use DocumentBuilder.Write method instead of DocumentBuilder.Writeln while inserting the text inside table's cell to fix the blank page issue. However, if you insert some more text in the last row of table, you may noticed this blank page. This is because there is one last paragraph in the document. This paragraph is the last paragraph in the Body (main text story) of a Section and Paragraph.IsEndOfSection returns true for this paragraph.

Hope this answers your query. Please let us know if you have any more queries.