Class

# PDFTable

<div class="rst-class">

forsearch

</div>

PDF

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A table that can appear in a `PDFDocument</api/pdf/pdfdocument>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                              | Type                                              | Read-Only | Shared |
|---------------------------------------------------|---------------------------------------------------|-----------|--------|
| `BottomMargin<pdftable.bottommargin>`             | `Double</api/data_types/double>`                  |           |        |
| `ColumnCount<pdftable.columncount>`               | `Integer</api/data_types/integer>`                |           |        |
| `ColumnWidths<pdftable.columnwidths>`             | `String</api/data_types/string>`                  |           |        |
| `DataSource<pdftable.datasource>`                 | `PDFTableDataSource</api/pdf/pdftabledatasource>` |           |        |
| `HasRepeatingHeader<pdftable.hasrepeatingheader>` | `Boolean</api/data_types/boolean>`                |           |        |
| `TopMargin<pdftable.topmargin>`                   | `Double</api/data_types/double>`                  |           |        |

## Property descriptions

<div id="pdftable.bottommargin">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.BottomMargin

**BottomMargin** As `Double</api/data_types/double>`

> The size of the bottom margin in points.

<div id="pdftable.columncount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.ColumnCount

**ColumnCount** As `Integer</api/data_types/integer>`

> The number of columns in the table.

<div id="pdftable.columnwidths">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.ColumnWidths

**ColumnWidths** As `String</api/data_types/string>`

> The widths of the columns separated by commas.

<div id="pdftable.datasource">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.DataSource

**DataSource** As `PDFTableDataSource</api/pdf/pdftabledatasource>`

> The `PDFTableDataSource</api/pdf/pdftabledatasource>` for the table.

<div id="pdftable.hasrepeatingheader">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.HasRepeatingHeader

**HasRepeatingHeader** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the header will be drawn again upon on each page the table is present.

<div id="pdftable.topmargin">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PDFTable.TopMargin

**TopMargin** As `Double</api/data_types/double>`

> The size of the top margin in points.

## Sample code

This example demonstrates adding a table to a new PDF document. *Self* in this case refers a `DesktopWindow</api/user_interface/desktop/desktopwindow>` implementing the `PDFTableDataSource</api/pdf/pdftabledatasource>` methods:

``` xojo
Var d As New PDFDocument
Var tTable As New PDFTable

tTable.ColumnCount = 3
tTable.ColumnWidths = "150,150,150"
tTable.DataSource = Self
tTable.HasRepeatingHeader = True

d.AddTable(tTable, 20, 20)
```

The following shows the implementation of the interface in Window1:

``` xojo
Public Function AddNewRow(rowCount As Integer) As Boolean
  ' Part of the PDFTableDataSource interface.
  Return rowCount < 100
End Function

Public Function HeaderHeight() As Double
  ' Part of the PDFTableDataSource interface.
  Return 30
End Function

Public Sub PaintHeaderContent(g As Graphics, column As Integer)
  ' Part of the PDFTableDataSource interface.

  Var c As Color

  Select Case Column
  Case 0
    c = Color.Red
  Case 1
    c = Color.Green
  Case 2
    c = Color.Blue
  End Select

  g.DrawingColor = c
  g.FillRectangle(0, 0, g.Width, g.Height)

  Var s As String = "Column: " + Column.ToString

  Var x, y As Double
  x = (g.Width / 2) - (g.TextWidth(s) / 2)
  y = (g.Height / 2) + (g.TextHeight / 2)

  g.DrawingColor = Color.Black
  g.DrawText(s, x, y)
End Sub

Public Sub PaintCell(g As Graphics, row As Integer, column As Integer)
  ' Part of the PDFTableDataSource interface.

  g.DrawingColor = Color.Black
  g.DrawRectangle(0, 0, g.Width, g.Height)

  Var s As String = "row: " + row.ToString + " column: " + Column.ToString
  Var h As Double = g.Height / 2 + g.TextHeight / 2
  g.DrawText(s, 5, h)

End Function

Public Function RowHeight() As Double
  ' Part of the PDFTableDataSource interface.
  return 25
End Function
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div id="pdftable.see_also">

<div class="seealso">

`PDFDocument</api/pdf/pdfdocument>` and `PDFTableDataSource</api/pdf/pdftabledatasource>`

</div>

</div>
