Free Support Forum -

Empty pages beginning of the document

I am using following code to create pdf file. First 13 pages are empty then it started printing the table.

How will I avoid these empty pages?


Public Sub dbread()

Dim sqlstr As String

Dim objConnection As New SqlConnection(conString)

sqlstr = "select * from staff where id <400"

Dim MyDataset As DataSet

Dim MyTable As DataTable

Dim loop1, numrows As Integer


Dim MyCommand As SqlDataAdapter = New SqlDataAdapter(sqlstr, objConnection)

' Fill a DataSet with data returned from the database.

MyDataset = New DataSet


' Create a new DataTable object and assign to it

' the new table in the Tables collection.

MyTable = New DataTable

MyTable = MyDataset.Tables(0)


objConnection.Close() ' Close the DB Connection

End Sub

Private Sub dbtopdf(ByVal dt As DataTable)


Dim i, pageWidth As Integer

Dim colwidth As String

colwidth = ""

pageWidth = 0

For i = 0 To dt.Columns.Count - 1

If dt.Columns(0).DataType Is System.Type.GetType("system.datetime") Then

colwidth = colwidth & " 50 "

pageWidth = pageWidth + 50


colwidth = colwidth & " 30 "

pageWidth = pageWidth + 30

End If


Dim pdf1 As Pdf = New Pdf

Dim sec1 As Section = pdf1.Sections.Add()

sec1.PageInfo.PageWidth = pageWidth

Dim tab1 As Aspose.Pdf.Table = New Aspose.Pdf.Table


tab1.ColumnWidths = colwidth

tab1.DefaultCellBorder = New BorderInfo(CType(BorderSide.All, Integer), 0.1F)

tab1.ImportDataTable(dt, True, 0, 1, dt.Rows.Count, dt.Columns.Count)

Dim row1 As Row = tab1.Rows(0)

Dim curCell As Cell

For Each curCell In row1.Cells

curCell.BackgroundColor = New Aspose.Pdf.Color("Blue")



Catch ex As Exception

Label1.Text = ex.Message

End Try

End Sub

Dear Sundaram,

Thank you for considering Aspose.

I can’t reproduce this error. Can you please send the resulting PDF document to me?