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?
Thanks
Sundaram
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 objConnection.Open() Dim MyCommand As SqlDataAdapter = New SqlDataAdapter(sqlstr, objConnection)
' Fill a DataSet with data returned from the database. MyDataset = New DataSet MyCommand.Fill(MyDataset) ' Create a new DataTable object and assign to it ' the new table in the Tables collection. MyTable = New DataTable MyTable = MyDataset.Tables(0) dbtopdf(MyTable) objConnection.Close() ' Close the DB Connection
End Sub Private Sub dbtopdf(ByVal dt As DataTable) Try 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 Else colwidth = colwidth & " 30 " pageWidth = pageWidth + 30 End If Next 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 sec1.Paragraphs.Add(tab1) 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") Next pdf1.Save("c:\test2.pdf") Catch ex As Exception Label1.Text = ex.Message End Try End Sub
|