ActivePDF
Shopping Cart My Account Help Contact Us
Request a Call
Search
Products Solutions Support Downloads Corporate
Submit an Issue
Knowledge Base
Server Product Support
Examples & How-Tos
Support Options
Support Policies
Annual Subscription
Extensions
Documentation
Resource Links
   
 
 
 
 

HomeSupportKnowledge Base
 
activePDF KB #11742 - Dynamically Generate a Table Grid
activePDF KB #11742 - Dynamically Generate a Table Grid
Information: Example Printer Version | Return to Search
Dynamically Generate a Table Grid
 
Product Version Code Samples    
Toolkit Lite
Toolkit Std
Toolkit Pro
4.0
VBS
ASP
 
Description
 
The following ASP example demonstrates how to dynamically generate a basic table grid in a PDF. This file is required:
  • Table-Grid.asp

NOTE: This example is available in other scripts. Choose from the Code Samples list above to display the download link for the language appropriate for your environment.

Click here to download this example for ASP (includes required file):

<%
' Variables
' New PDF name
strOutputName = Server.MapPath("Table.pdf")

' Page Title Properties
strTitleText = "Table create using DrawTo and PrintMultilineText"
strTitleFont = "Helvetica"
fltTitleFontSize = 24

' Page dimensions (72 units = 1 inch)
fltPageHeight = 792
fltPageWidth = 612

' Margins for Table
fltMarginLeft = 72
fltMarginRight = 72
fltMarginTop = 144
fltMarginBottom = 72

' Table header properties (0 font size = auto size)
strHeadFont = "Helvetica Bold"
fltHeadFontSize = 12

' Table body properties (0 font size = auto size)
strBodyFont = "Helvetica"
fltBodyFontSize = 10

' Table variables
intVisableLines = 1

' Common field and line variables
intTotalRows = 24
intTotalCols = 5
fltRowHeight = (fltPageHeight - fltMarginTop - fltMarginBottom) / intTotalRows
fltColWidth = (fltPageWidth - fltMarginLeft - fltMarginRight) / intTotalCols
fltMaxTableHeight = fltPageHeight - fltMarginTop - fltMarginBottom
fltMaxTableRows = fltMaxTableHeight \ fltRowHeight
fltMaxTableWidth = fltPageWidth - fltMarginLeft - fltMarginRight
fltMaxTableCols = fltMaxTableWidth \ fltColWidth
fltStartLocX = fltMarginLeft
fltStartLocY = fltPageHeight - fltMarginTop
fltEndLocX = fltPageWidth - fltMarginRight
fltEndLocY = fltMaxTableRows * fltRowHeight

' Visable line properties
intLineWidth = 1

' Added form field properties
fltTableWidth = fltPageWidth - fltMarginLeft - fltMarginRight


' Instantiate Object
Set objTK = CreateObject("APToolkit.Object")

' OpenOutputFile
lngReturn = objTK.OpenOutputFile(strOutputName)
If lngReturn <> 0 Then
errorRtn "OpenOutputFile", lngRtn

Else
objTK.SetFont strTitleFont, fltTitleFontSize, 0
fltTextWidth = objTK.GetTextWidth(strTitleText)
objTK.PrintText (fltPageWidth / 2) - (fltTextWidth / 2), 720, strTitleText, 0

If intVisableLines = 1 Then
' Start drawing process
objTK.LineWidth intLineWidth, 0
objTK.MoveTo fltStartLocX, fltStartLocY, 0

' Horizontal lines
fltCurrentY = fltStartLocY
For intA = 0 to fltMaxTableRows
objTK.DrawTo fltEndLocX, fltCurrentY, 0
fltCurrentY = fltCurrentY - fltRowHeight
objTK.MoveTo fltMarginLeft, fltCurrentY, 0

Next

fltEndLocY = fltCurrentY + fltRowHeight
objTK.MoveTo fltStartLocX, fltStartLocY, 0

' Vertical Lines
fltCurrentX = fltStartLocX
For intB = 0 to fltMaxTableCols + 1
objTK.DrawTo fltCurrentX, fltEndLocY, 0
fltCurrentX = fltCurrentX + fltColWidth
objTK.MoveTo fltCurrentX, fltStartLocY, 0

Next

End If

' CloseOutputFile
objTK.CloseOutputFile

Response.Write "Done!"

End If

' Release Toolkit object
Set objTK = Nothing

' Error Return Handling
Sub errorRtn(strMethod, RtnCode)
Response.Write strMethod & " error: " & RtnCode & _
"
" & _

"Return Codes
"

End Sub
%>
 
Keywords
 
OpenOutputFile, GetTextWidth, PrintText, DrawTo, MoveTo, CloseOutputFile, generate, create, generated, form, forms, configure, parameters, build, invoice, table, how, to, method, property, methods, properties, pdf, pdfs, VBS, VBScript, vb, script, example
 
Last Updated 2008-03-25 Printer Version | Return to Search
 
Knowledge Base Article Feedback*
*KB article feedback ONLY (submit support issues here)
Quality of this article?
  Poor Excellent 
1 2 3 4 5 6 7 8 9 10
Is this article helpful? Yes       No       Maybe
Comments (Optional)
Email Address (Optional)
Please enter the word "PDF"
(without quotes)
 
The information in this article is for the use of activePDF Customers and Evaluation Users Only. No part of this document may be transmitted or reproduced without the express written consent of activePDF.

Copyright © 2005, activePDF, Inc. All Rights Reserved
2003 activePDF Site Map Feedback Privacy Policy Legal