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.