The PDFDoc Scout SDK product has been acquired by Lionsoft company in January, 2011 and not available on our web-site anymore.

NEW: pdf generator for Web Developers: PDF Generator SDK for Javascriptclick here to read more details...


For 3rd party C# open-source PDF generation library? Check the blog article: .NET Bear, Do You Know Any Free PDF Generation Libraries For Use In Commercial Applications?
 

Check our commercial products for PDF format:

PDF Extractor SDK - extract tables, text, structured data from PDF files in your apps

PDF Renderer SDK - render PDF files to PNG, BMP, TIFF images in your apps

PDF To HTML SDK - convert PDF to HTML with images and formatting preserved

Drawing tables in PDF document using HTML formatting supported in PDFDoc Scout library

How to draw tables to PDF document using HTML text format and PDFDoc Scout library: 

You can download the source code of this example here: pdfdocscout_drawing_table_using_html_formatting.zip

This example describes how to draw tables in generated PDF document with easy using built-in HTML text formatting support in PDFDoc Scout library

Screenshot of generated PDF document with HTML coded table:

Table created using HTML text formatting in PDF document generated by PDFDoc Scout

Code to compose HTML code for table and draw this table in PDF:

PDFDoc.InitLibrary "demo", "demo"
PDFDoc.OutputFilename = "draw_table.pdf"
PDFDoc.AutoOpenGeneratedPDF = true

 

PDFDoc.BeginDocument

' compose HTML code for Table with 4 columns and 5 rows (header + 4 rows)
TableHeader = "<table border='1' cellspacing='2'>"
TableFooter = "</table>"

Dim RowHeaders(5), RowFooters(5), Cells(5)

RowHeaders(1) = "<tr bgcolor='#0000CC'>" ' header row
RowHeaders(2) = "<tr bgcolor='#CCCCCC'>"
RowHeaders(3) = "<tr>"
RowHeaders(4) = "<tr bgcolor='#CCCCCC'>"
RowHeaders(5) = "<tr>"

RowFooters(1) = "</tr>" ' header row
RowHeaders(2) = "</tr>"
RowHeaders(3) = "</tr>"
RowHeaders(4) = "</tr>"
RowHeaders(5) = "</tr>"


' Header cells
Cells(1) = "<td valign='middle'><font color='#FFFFFF'><strong>Computer location</strong></font></td>" & "<td valign='middle'> <font color='#FFFFFF'><strong>Does it have a network adapter?</strong></font></td>" & "<td valign='middle'> <font color='#FFFFFF'><strong>What kind of modem?</strong></font></td>" & "<td valign='middle'> <font color='#FFFFFF'><strong>Other hardware devices</strong></font></td>"
' data cells
Cells(2) = "<td valign='middle'>Den</td><td valign='middle'> Ethernet</td><td valign='middle'> <p align='center' >DSL</p></td><td valign='middle'> Printer, scanner</td>"
Cells(3) = "<td valign='middle'>Son's bedroom</td><td valign='middle'> No</td><td valign='middle'> <p align='center' >56 kilobits per second (Kbps) analog modem</td></p> <td valign='middle'> Digital camera</td>"
Cells(4) = "<td valign='middle'>Daughter's bedroom</td><td valign='middle'> No</td><td valign='middle'> <p align='center' >No modem</p></td><td valign='middle'> Scanner</td>"
Cells(5) = "<td valign='middle'><img src='sample.png' width=48 height=48><br/>Library</td><td valign='middle'>Ethernet</td><td valign='middle'><p align='center' >No modem</p></td><td valign='middle'>Printer</p></td>"

' now composing HTML code for whole table
TableCode = TableHeader

For i=1 to 5
' add new row and its header
TableCode = TableCode & RowHeaders(i)
' add cells for this row
TableCode = TableCode & Cells(i)
' add row footer
TableCode = TableCode & RowFooters(i)
Next

' adding table footer
TableCode = TableCode & TableFooter

' finally add HTML box to the current page

PDFDoc.Page.AddHTMLBox TableCode, 20,80,PDFDoc.Page.Width-40, PDFDoc.Page.Height-40, false

PDFDoc.EndDocument ' close PDF document generation

' disconnect from library
Set PDFDoc = Nothing

You can download the source code of this example here: pdfdocscout_drawing_table_using_html_formatting.zip 

Filed in: PDFDoc Scout SDK

Tutorials: