Step 2 - Insert a Table

ASP User's Guide > Simple Sample Programs

In the second step, step2.asp, a more advanced document is generated. A table is inserted and its cells are filled with text.

tx.TableInsert 2, 2, -1, 11	' inserts a 2x2 table 
tx.TableCellText(11, 1,1) = "Cell 0,0"
tx.TableCellText(11, 1,2) = "Cell 0,1"
tx.TableCellText(11, 2,1) = "Cell 1,0"
tx.TableCellText(11, 2,2) = "Cell 1,1"

The TableInsert method is used to add a table to the generated document. The last parameter of this method is a unique identifier for the table. This identifier can be used to alter the table or its cells dynamically. The example uses this identifier as a parameter to TableCellText to address the previously inserted table.

Furthermore there is also another interesting code fragment that deals with PDF output. As you can see, the generated document is not saved in a file. The sample script sends the PDF output directly to the client's browser:

binPDF = tx.SaveToMemoryBuffer (binPDF, 12, 0)
Response.Clear
Response.ContentType = "application/pdf"
Response.BinaryWrite(binPDF)

With the SaveToMemoryBuffer method the document is stored in a memory buffer identified through the binPDF variable. Using this it is possible to send the whole document to the client's browser. It also could be encoded and sent as attachment via e-mail.