Sets the target PDF for a
table.
Use this function to continue
drawing a table on new pdf pages.
The function changes the PDF
instance that is associated with the table.
The PDF instance must be
changed if the table should be drawn into another PDF instance
as the one for which the
table was created.
Parameters:
Name |
Type |
Description |
tblHandle |
Integer |
The identification number (handle) of a table, obtained from the PdfTableCreate
function. |
Available in:
WindowMain |
WindowLink |
YES |
YES |
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 '%PdfTableSetPdf%'
Example XojoScript:
Dim
width As Double
= 150.0
Dim
rows As Integer
= 50
Dim
x,y As Double
= 30.0
Dim
pageCounter As Integer
= 0
If
PdfStart("testfile.pdf")
> 0 Then
// sets a predefined page
or paper format
Call PdfSetPageformat("E6") // 312.0 x
439.0
PdfSetPageCoordsTopDown // Set top top-left as 0,0 coordinates
PdfSetFont("Arial","Regular",10.0) // Set output
font
Call PdfSetFillColor("&c00000000")
// // Set black textcolor
pageCounter = pageCounter + 1 // increase page counter
Call PdfWriteText(x,y,"Page
" + Str(pageCounter)) // write page
number
Dim hTbl As Integer = PdfTableCreate(rows,2,width,9.0)
If hTbl >= 0 Then
Call PdfTableSetColumnWidth(hTbl, 0, 20.0, False) // Set width of
first colum, the last column autoadjusts
Call PdfTableSetFont(hTbl,-1,
-1, "Arial",
10.0, "Regular")
// Set Font, Size and Style for table
Call PdfTableSetBorderWidth(hTbl,-1, -1, 0.0, 0.5, 0.0, 0.5) // Set outer border
Call PdfTableSetGridWidth(hTbl, 0.5,0.5) // Set inner gridlines
Call PdfTableSetCellPadding(hTbl,-1, 1, 5.0, 0.0, 5.0, 0.0) // column 2 (1st column is 0)
Dim rowNum As Integer = 0 // Hold number of
PDFTableRows created
rowNum = PdfTableAddRow(hTbl)
// Add header row
// All columns of first
row are set as headers
Call PdfTableSetflags(hTbl,rowNum,-1,2)
// Add header text
Call PdfTableSetCellText(hTbl,rowNum, 0, "Left", "Top",
"NO.")
Call PdfTableSetCellText(hTbl,rowNum, 1, "Right", "Top",
"ITEM")
// Add all rows to table
and insert some text to cells
For i As Integer = 0 To rows-1
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
y = y + 30.0
// Set new vertical position
Do // Now draw table to pdf and add pages if necessary
Call PdfTableDraw(hTbl,x,y,250.0)
// 250.0= Maximum height of table, 0.0 = avoid
pagebreaks
If PdfTableHaveMore(hTbl) Then
Call PdfEndpage //
Terminate page
Call PdfAppend
// Add a new page
y = 30.0
// Reset vertical position
PdfSetFont("Arial","Regular",10.0) // Define font
for new page and write text
pageCounter = pageCounter + 1 // Increase page number
Call PdfWriteText(x,y,"Page
" + Str(pageCounter)) // write page
number
y = y + 30.0
// Set vertical position for table to continue
PdfTableSetPdf(hTbl) // Expand table to new pdf page
Else
Exit // terminate
loop
End If
Loop
End If // hTbl >= 0
Call PdfcloseFile //
Finalize PDF
Call pdflaunch // Show it
to the user
End
If