Class

PDFTable


Description

A table that can appear in a PDFDocument.

Property descriptions


PDFTable.BottomMargin

BottomMargin As Double

The size of the bottom margin in points.


PDFTable.ColumnCount

ColumnCount As Integer

The number of columns in the table.


PDFTable.ColumnWidths

ColumnWidths As String

The widths of the columns separated by commas.


PDFTable.DataSource

DataSource As PDFTableDataSource

The PDFTableDataSource for the table.


PDFTable.HasRepeatingHeader

HasRepeatingHeader As Boolean

If True, the header will be drawn again upon on each page the table is present.


PDFTable.TopMargin

TopMargin As 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 implementing the PDFTableDataSource methods:

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:

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

Desktop, console, web and iOS project types on all supported operating systems.