DynaPDF.Table.Draw
------------------

Draws the table on the specified position.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.Table.Draw"; Table; X; Y; MaxHeight ) 

**MBS**( **"DynaPDF.Table.Draw";** /\* Draws the table on the specified position. \*/  
**$Table**; /\* The identifier for the table. \*/   
**$X**; /\* The x position where to draw the table.e.g. 100 \*/   
**$Y**; /\* The y position where to draw the table.e.g. 100 \*/   
**$MaxHeight**) /\* The maximum height to use for the table.e.g. 600 \*/ 

### 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](DynaPDFTableHaveMore.md)"; $table ) ≠ 1 \]  
 #Add another page  
 Set Variable \[$r ; Value:MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf )\]  
 Set Variable \[$r ; Value:MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $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](DynaPDFIsInitialized.md)") ≠ 1 \]  
 Perform Script \[ “InitDynaPDF” \]  
End If  
  
\# Clear current PDF document   
Set Variable \[ $pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)") \]  
\# coordinates top down instead the default Bottom Up   
Set Variable \[ $r ; Value:MBS ("[DynaPDF.SetPageCoords](DynaPDFSetPageCoords.md)"; $pdf ; "TopDown") \]  
  
\# Create Table   
Set Variable \[ $table ; Value:MBS ("[DynaPDF.Table.Create](DynaPDFTableCreate.md)"; $pdf ; 3; 3; 500; 100) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetBorderWidth](DynaPDFTableSetBorderWidth.md)"; $table ; -1; -1; 1; 1; 1; 1) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetGridWidth](DynaPDFTableSetGridWidth.md)"; $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](DynaPDFTableAddRow.md)"; $table ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 0; "left"; "top"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 1; "center"; "top"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 2; "right"; "top"; $text ) \]  
Set Variable \[ $rowNum ; Value:MBS ("[DynaPDF.Table.AddRow](DynaPDFTableAddRow.md)"; $table ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 0; "left"; "center"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 1; "center"; "center"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 2; "right"; "center"; $text ) \]  
Set Variable \[ $rowNum ; Value:MBS ("[DynaPDF.Table.AddRow](DynaPDFTableAddRow.md)"; $table ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 0; "left"; "bottom"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 1; "center"; "bottom"; $text ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)"; $table ; $rowNum ; 2; "right"; "bottom"; $text ) \]  
  
\# Draw Table (just one page without loop)   
Set Variable \[ $r ; Value:MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf ) \]  
Set Variable \[ $r ; Value:MBS ("DynaPDF.Table.Draw"; $table ; 50; 50; 742) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
  
\# Cleanup   
Set Field \[ Tables::OutputPDF ; MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Table.Release](DynaPDFTableRelease.md)"; $table ) \]  
Set Variable \[ $r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.IsInitialized](DynaPDFIsInitialized.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.Table.AddRow](DynaPDFTableAddRow.md)
- [DynaPDF.Table.Create](DynaPDFTableCreate.md)
- [DynaPDF.Table.GetFirstRow](DynaPDFTableGetFirstRow.md)
- [DynaPDF.Table.GetNextRow](DynaPDFTableGetNextRow.md)
- [DynaPDF.Table.List](DynaPDFTableList.md)
- [DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)

### Example Databases

- [DynaPDF/Book Creation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Book%20Creation.shtml#3ScriptAnchor_)
- [DynaPDF/Catalog with tables](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Catalog%20with%20tables.shtml#1ScriptAnchor_)
- [DynaPDF/Invoice/Invoice](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Invoice/Invoice.shtml#3ScriptAnchor_)
- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#5ScriptAnchor_)
- [DynaPDF/Report](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Report.shtml#1ScriptAnchor_)
- [DynaPDF/Tables](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Tables.shtml#1ScriptAnchor_)

### Blog Entries

- [Merge PDF with table of contents](https://www.mbsplugins.de/archive/2020-02-25/Merge_PDF_with_table_of_conten/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 7th January 2023

  
[DynaPDF.Table.DeleteRows](DynaPDFTableDeleteRows.md) - [DynaPDF.Table.GetFirstRow](DynaPDFTableGetFirstRow.md)

[HTML Version](DynaPDFTableDraw.shtml)