1. Dim doc1 As New Document()
2. Dim path As String
3. path = "C:\Users\Dave\documents\visual studio 2010\Projects\QualitechInterface\QualitechInterface\PDFs\"
4. PdfWriter.GetInstance(doc1, New FileStream(path + "Doc1.pdf", FileMode.Create))
5. doc1.Open()
6. Dim tbl As New PdfPTable(3)
7.
8.
9.
10. Dim connectionString As String = "Server=Dave-PC\Qualitech;Database=QualitechPortal;Trusted_Connection=True;"
11. Dim cn As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectionString)
12. cn.Open()
13. Dim command As New SqlClient.SqlCommand()
14. command.Connection = cn
15. command.CommandText = "Select Number, Name, Description From Numbering"
16. command.ExecuteNonQuery()
17. Dim sqlDa As New SqlClient.SqlDataAdapter(command)
18. Dim dt As New DataTable
19. tbl.AddCell(dt.Rows(0)("Number").ToString)
20. tbl.AddCell(dt.Rows(1)("Name").ToString)
21. tbl.AddCell(dt.Rows(2)("Description").ToString)
22.
23. doc1.Add(tbl)
24. doc1.Close()
Ok so the code i have so far is as shown above. This works on the most part however when producing the table in the pdf if only adds the first row into the table then adds no more information any idea why this is? Also while I am on the topic; I am wanting
to make it so that there is a table above and below the main table that will have compnay information, this means there will only be a limited amount of space for the main table, can I automate it so that if the main table is too large iTextSharp will produce
a new page add the header and footer and add the files to the main table?
Does anybody out there know how to add headers and footers using itextsharp 5, from what I can find on the net most websites use iTextSharp and they seem to be different methods...
itsmemuthu
Contributor
3947 Points
698 Posts
Re: iTextSharp
Jul 21, 2010 11:32 AM|LINK
fine.. why dont you fill ur data to a gridview and export it to PDF
Muthu
Remember To Click Mark As Answer On the Post That Helps U
ChewyNorman
Member
49 Points
102 Posts
Re: iTextSharp
Jul 22, 2010 07:55 AM|LINK
I found a decent example of using iTextSharp using VB if anyone is looking for one....
http://www.jlion.com/docs/itextsharp.aspx
Chris
ChewyNorman
Member
49 Points
102 Posts
Re: iTextSharp
Jul 22, 2010 09:27 AM|LINK
1. Dim doc1 As New Document() 2. Dim path As String 3. path = "C:\Users\Dave\documents\visual studio 2010\Projects\QualitechInterface\QualitechInterface\PDFs\" 4. PdfWriter.GetInstance(doc1, New FileStream(path + "Doc1.pdf", FileMode.Create)) 5. doc1.Open() 6. Dim tbl As New PdfPTable(3) 7. 8. 9. 10. Dim connectionString As String = "Server=Dave-PC\Qualitech;Database=QualitechPortal;Trusted_Connection=True;" 11. Dim cn As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectionString) 12. cn.Open() 13. Dim command As New SqlClient.SqlCommand() 14. command.Connection = cn 15. command.CommandText = "Select Number, Name, Description From Numbering" 16. command.ExecuteNonQuery() 17. Dim sqlDa As New SqlClient.SqlDataAdapter(command) 18. Dim dt As New DataTable 19. tbl.AddCell(dt.Rows(0)("Number").ToString) 20. tbl.AddCell(dt.Rows(1)("Name").ToString) 21. tbl.AddCell(dt.Rows(2)("Description").ToString) 22. 23. doc1.Add(tbl) 24. doc1.Close()Ok so the code i have so far is as shown above. This works on the most part however when producing the table in the pdf if only adds the first row into the table then adds no more information any idea why this is? Also while I am on the topic; I am wanting to make it so that there is a table above and below the main table that will have compnay information, this means there will only be a limited amount of space for the main table, can I automate it so that if the main table is too large iTextSharp will produce a new page add the header and footer and add the files to the main table?
Thanks
Chris
ChewyNorman
Member
49 Points
102 Posts
Re: iTextSharp
Jul 22, 2010 03:32 PM|LINK
Anyone out there that can help?? please
ChewyNorman
Member
49 Points
102 Posts
Re: iTextSharp
Jul 26, 2010 07:53 AM|LINK
Does anybody out there know how to add headers and footers using itextsharp 5, from what I can find on the net most websites use iTextSharp and they seem to be different methods...
I really need some help on this if you can
Thanks