Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.Table.Draw
Draws the table on the specified position.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
Table | The identifier for the table. | $Table |
x | The x position where to draw the table. | 100 |
y | The y position where to draw the table. | 100 |
MaxHeight | The maximum height to use for the table. | 600 |
Result
Returns height or error.
Description
Draws the table on the specified position.The x/y-coordinates specify the top left corner of the table. The table flows always from top to bottom.
The function must be executed in a while statement if the parameter MaxHeight is set to a value greater zero:
The function draws the header rows if any and at least one row to avoid an endless loop if the maximum height would be smaller as the first row height.
If the function succeeds the return value is the height of the table that was drawn so that additional contents can be drawn below the table if necessary. If the function fails the return value is -1.
Examples
Loop to draw table and add pages as needed:
Set Variable [$h; Value:300]
Set Variable [$y; Value:200]
Loop
#Draw something on page
Set Variable [$r; Value:MBS("DynaPDF.Table.Draw"; $table; 58; $y; $h)]
Set Variable [$y; Value:$y + $r + 5]
Exit Loop If [ MBS("DynaPDF.Table.HaveMore"; $table) ≠ 1 ]
#Add another page
Set Variable [$r; Value:MBS("DynaPDF.EndPage"; $pdf)]
Set Variable [$r; Value:MBS("DynaPDF.AppendPage"; $pdf)]
Set Variable [$h; Value:580]
Set Variable [$y; Value:120]
End Loop
Complete example using a simple table on one page:
# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
Perform Script [ “InitDynaPDF” ]
End If
# Clear current PDF document
Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
# coordinates top down instead the default Bottom Up
Set Variable [ $r; Value:MBS("DynaPDF.SetPageCoords"; $pdf; "TopDown") ]
# Create Table
Set Variable [ $table; Value:MBS("DynaPDF.Table.Create"; $pdf; 3; 3; 500; 100) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $table; -1; -1; 1; 1; 1; 1) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetGridWidth"; $table; 1; 1) ]
# Add Rows
Set Variable [ $text; Value:"The cell alignment can be set for text, images, and templates..." ]
Set Variable [ $rowNum; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 0; "left"; "top"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 1; "center"; "top"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 2; "right"; "top"; $text) ]
Set Variable [ $rowNum; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 0; "left"; "center"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 1; "center"; "center"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 2; "right"; "center"; $text) ]
Set Variable [ $rowNum; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 0; "left"; "bottom"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 1; "center"; "bottom"; $text) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 2; "right"; "bottom"; $text) ]
# Draw Table (just one page without loop)
Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.Draw"; $table; 50; 50; 742) ]
Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
# Cleanup
Set Field [ Tables::OutputPDF; MBS("DynaPDF.Save"; $pdf) ]
Set Variable [ $r; Value:MBS("DynaPDF.Table.Release"; $table) ]
Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
See also
- DynaPDF.IsInitialized
- DynaPDF.New
- DynaPDF.Release
- DynaPDF.Save
- DynaPDF.SetPageCoords
- DynaPDF.Table.GetNextRow
- DynaPDF.Table.HaveMore
- DynaPDF.Table.Release
- DynaPDF.Table.SetBorderWidth
- DynaPDF.Table.SetGridWidth
Example Databases
- DynaPDF/Book Creation
- DynaPDF/Catalog with tables
- DynaPDF/Invoice/Invoice
- DynaPDF/Merge PDFs
- DynaPDF/Report
- DynaPDF/Tables
Blog Entries
This function checks for a license.
Created 18th August 2014, last changed 7th January 2023