- Home
- Products For Home & Business
- Tools For Developers
- Download
- Purchase
- Support
- Company
QUESTIONS OR COMMENTS ABOUT PRODUCTS? WRITE US AT SUPPORT@BYTESCOUT.COM OR USE THIS FORM
QUESTIONS OR COMMENTS ABOUT PRODUCTS? WRITE US AT SUPPORT@BYTESCOUT.COM OR USE THIS FORM
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

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
Tutorials: