Add a row to a table
Parameters:
Name |
Type |
Description |
tblHandle |
Integer |
The identification number (handle) of a table, obtained from the PdfTableCreate
function. |
height |
Double |
The specification of the rowheight is optional. The height represents the
minumum height of each row. If the height of a foreground object is larger, then the row
height will be adjusted. Example row height: 15.0 The parameter height can be
set to a negative value to indicate that the default row height should be
used. The default row height was specified in PdfTableCreate. |
Returns:
Type |
Value |
Description |
Integer |
>=
0 |
number of added row |
Integer |
-1 |
failed to add a row |
Integer |
-2 |
An unknown exception occured |
Available in:
WindowMain |
WindowLink |
YES |
YES |
Used in:
XojoScript
Name |
GUID |
Create
Seminar Invoice With Slip As PDF |
739DA58E-17EE-41CE-BB54-E7362CFE17D4 |
Create
Seminar Invoice As PDF |
2C3F7F29-A29A-4338-ACF5-51894B709DA5 |
Hint: You can find
references to XojoScripts which make use of this function by sending the
following SQL statement to the database:
Select id,GUID, ScriptName,ScriptCode from
im_scripts where ScriptCode Like '%PdfTableAddRow%'
Example XojoScript:
Const
AllRows = -1
Const
AllColumns = -1
Dim
mainfont As String
= "Arial"
Dim
fontsize As Double
= 10.0
Dim
width As Double
= 200.0
Dim
rows As Integer
= 2
Dim
x,y As Double
= 30.0
If
PdfStart("testfile.pdf")
> 0 Then
// Set top top-left as
0,0 coordinates
PdfSetPageCoordsTopDown
// Set output font and
color
PdfSetFont("Arial","Regular",10.0)
Call PdfSetFillColor("&c00000000")
// black textcolor
Dim hTbl As Integer = PdfTableCreate(2,2,width,9.0)
If hTbl >= 0 Then
// Set the first four columnwidths,
the 2nd column autoadjusts
Call PdfTableSetColumnWidth(hTbl, 0, 20.0, False)
// Set Font, Size and
Style for table
Call PdfTableSetFont(hTbl,AllRows, AllColumns,
mainfont, fontsize, "Regular")
// Set outer border
Call PdfTableSetBorderWidth(hTbl,AllRows, AllColumns, 0.0, 0.5, 0.0, 0.5)
// Set inner gridlines
Call PdfTableSetGridWidth(hTbl, 0.5,0.5)
// Set Padding (distance
from Text to Cellborder)
Call PdfTableSetCellPadding(hTbl,AllRows, 1, 5.0, 0.0, 5.0, 0.0)
// Hold number of PDFTableRows
created
Dim rowNum As Integer = 0
For i As Integer = 0 To rows-1
// Add a row
rowNum = PdfTableAddRow(hTbl)
Dim cnt As String =
Str(rowNum+1)
Call PdfTableSetCellText(hTbl,rowNum, 0, "Left", "Top",
cnt)
Call PdfTableSetCellText(hTbl,rowNum, 1, "Right", "Top",
"Item" + cnt)
Next // i
// Draw the table out to
pdf
Call PdfTableDraw(hTbl,x,y,0.0)
// 0.0 = avoid pagebreaks
End If // hTbl >= 0
// Finalize PDF
Call PdfCloseFile
// Open PDF in default
viewer
Call Pdflaunch
End
If //
PdfStart("testfile.pdf")