Queries next row of last draw
operation.
The function returns the
index of the next row that will be drawn when PdfTableDraw is called the next time.
The pdf file shown in this
picture is created by the example script
below. The PdfTableGetNextRow
function is used to calculate the record
counters in the heading
Parameters:
Name |
Type |
Description |
tblHandle |
Integer |
The identification number (handle) of a table, obtained from the PdfTableCreate
function. |
Returns:
Type |
Value |
Description |
Integer |
0 or
higher |
returns the index of the next row to be drawn when PdfTableDraw is
called the next time. Returns -1 on failure |
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 '%PdfTableGetNextRow%'
Example XojoScript:
Dim
rows As Integer
= 100
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,150.0,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",
8.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
Call PdfTableSetflags(hTbl,rowNum,-1,2) // All
columns of first row are set as headers
Call PdfTableSetCellText(hTbl,rowNum, 0, "Left", "Top",
"NO.") //
Add header text
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)
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
Dim recsP1 As Integer = 0 // Store number or
records on first page
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
Dim firstrow As Integer = PdfTableGetFirstRow(hTbl) // get index
of first row on page
Dim nextrow As Integer = PdfTableGetNextRow(hTbl)-1
// get index of last row on page
If pagecounter = 1 Then
Call PdfWriteText(x+80.0,y-30.0 ,"Record
" + Str(firstrow+1) + " to " + Str(nextrow))
recsP1=nextrow
End If
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
If pagecounter = 2 Then firstrow =
firstrow + 1 // adjust
firstrow on page2
Call PdfWriteText(x+70.0,y,
"Records " + Str(firstrow+recsP1)
_
+ " to
" + Str(If(nextrow+recsP1>rows,rows,nextrow+recsP1)))
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