Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Creates a new table object.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
The PDF reference returned from DynaPDF.New. | ||
AllocRows | The number of rows to preallocate. | 10 |
NumCols | The number of columns. | 5 |
Width | The width of table. | 500 |
DefRowHeight | The default row height for a new row. | 30 |
Returns table identifier or error.
Create table with 10 preallocated rows, 2 columns, 500 point width and 10 point default row height:
MBS("DynaPDF.Table.Create"; $pdf; 10; 2; 500; 10)
Create table and set some properties:
Set Variable [$table; Value:MBS("DynaPDF.Table.Create"; $pdf; 10; 2; 500; 10)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $table; -1; -1; 1; 1; 1; 1)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "BorderColor"; 255; 255; 255)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "GridHorzColor"; 255; 255; 255)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "GridVertColor"; 255; 255; 255)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "TextColor"; 0; 0; 0)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetGridWidth"; $table; 10; 10)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 0; 200;1)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 1; 300;1)]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetFont"; $table; -1; -1; "Helvetica"; 0; 1; "unicode")]
Set Variable [$r; Value:MBS("DynaPDF.Table.SetFontSize"; $table; -1; -1; 10)]
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) ]
Create table for foot notes:
Set Variable [ $FootNotes ; Value: MyTable::FootNotes ]
If [ Length ( $FootNotes ) > 0 ]
#
# Create footnotes Table
Set Variable [ $table ; Value: MBS("DynaPDF.Table.Create"; $pdf; 5; 2; 240; 20) ]
# default font for cells
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetFontSize"; $table; -1; -1; 12) ]
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetFont"; $table; -1; -1; "Helvetica"; 0; 1; "unicode") ]
# no border
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetBorderWidth"; $table; -1; -1; 0; 0; 0; 0) ]
# but a bit of spacing inside cells
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetCellSpacing"; $table; -1; -1; 1; 1; 1; 1) ]
# no grid
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetGridWidth"; $table; 0; 0) ]
# first column only 10pt wide
Set Variable [ $r ; Value: MBS( "DynaPDF.Table.SetColWidth"; $Table; 0; 10; 0 ) ]
#
# Loop over footnote lines
Set Variable [ $count ; Value: ValueCount ( $FootNotes) ]
Set Variable [ $index ; Value: 1 ]
If [ $index ≤ $count ]
Loop
# place a footnote in a new row
Set Variable [ $value ; Value: GetValue($FootNotes; $index) ]
Set Variable [ $rowNum ; Value: MBS("DynaPDF.Table.AddRow"; $table) ]
# left the number with superscript
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 0; "left"; "top"; "\TR[4]\FS[8]" & $index & "\TR[0]\FS[12]") ]
# right the normal text. Can wrap to multiple lines, if it is long
Set Variable [ $r ; Value: MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 1; "left"; "top"; $value) ]
#
# next
Set Variable [ $index ; Value: $index + 1 ]
Exit Loop If [ $index > $count ]
End Loop
End If
#
# Draw Table, first get height of it
Set Variable [ $height ; Value: MBS( "DynaPDF.Table.GetTableHeight"; $Table ) ]
# we can position it. With height we can calculate distance from bottom to put it on the page
Set Variable [ $r ; Value: MBS("DynaPDF.Table.Draw"; $table; 620; 20+$height; 742) ]
# free memory
Set Variable [ $r ; Value: MBS("DynaPDF.Table.Release"; $table) ]
End If
Created 18th August 2014, last changed 28th May 2021
DynaPDF.Table.ClearRow - DynaPDF.Table.DeleteCol
Feedback: Report problem or ask question.