Skip to content

Table ​

Defined in: components/table.ts:67

Implements ​

Constructor components/table.ts:83 ​

new Table(options): Table

Parameters ​

ParameterType
object
aligns?("left" | "center" | "right")[]
alternateRowBackgroundColor?string | Color
backgroundColor?string | Color
borderColor?string | Color
borderWidth?number
columns(string | number)[]
headerBackgroundColor?string | Color
padding?number | {
bottom?: number;
left?: number;
right?: number;
top?: number;
}
repeatHeader?boolean
valign?"top" | "middle" | "bottom"
valigns?("top" | "middle" | "bottom")[]

Returns ​

Table

Properties ​

PropertyModifierTypeDefault value
aligns?
table.ts:78
public("left" | "center" | "right")[]undefined
alternateRowBackgroundColor?
table.ts:75
publicstring | Colorundefined
backgroundColor?
table.ts:73
publicstring | Colorundefined
borderColor
table.ts:72
publicstring | Colorundefined
borderWidth
table.ts:71
publicnumberundefined
columns
table.ts:68
public(string | number)[]undefined
headerBackgroundColor?
table.ts:74
publicstring | Colorundefined
headers
table.ts:70
publicTableCell[][]
padding?
table.ts:76
publicnumber | {
bottom?: number;
left?: number;
right?: number;
top?: number;
}
undefined
repeatHeader
table.ts:77
publicbooleanundefined
rows
table.ts:69
publicTableCell[][][]
templateRows
table.ts:81
publicobject[][]
valign?
table.ts:79
public"top" | "middle" | "bottom"undefined
valigns?
table.ts:80
public("top" | "middle" | "bottom")[]undefined

Methods ​

addHeader() components/table.ts:132 ​

addHeader(row): this

Parameters ​

ParameterType
rowCellContent[]

Returns ​

this

addRow() components/table.ts:137 ​

addRow(row): this

Parameters ​

ParameterType
rowCellContent[]

Returns ​

this

addTemplateRow() components/table.ts:142 ​

addTemplateRow(arrayPath, cells): this

Parameters ​

ParameterType
arrayPathstring
cellsCellContent[]

Returns ​

this

draw() components/table.ts:192 ​

draw(writer, x, y, width, availableHeight, context): Component | null

Draws the component (or a part of it) on the page.

Parameters ​

ParameterTypeDescription
writerPDFPageWriterThe page writer to issue commands to.
xnumberThe current relative X coordinate from the left margin.
ynumberThe current relative Y coordinate from the bottom margin (top boundary of the element).
widthnumberThe width constraint allocated to this element.
availableHeightnumberThe height constraint representing remaining space on the current page.
contextLayoutContextThe layout configuration context.

Returns ​

Component | null

A new Component representing the remainder of this component if it could not finish rendering, or null if it rendered completely.

Implementation of ​

Component.draw

getHeaderHeight() components/table.ts:163 ​

getHeaderHeight(width, context): number

Parameters ​

ParameterType
widthnumber
contextLayoutContext

Returns ​

number

measure() components/table.ts:171 ​

measure(width, context): object

Returns the width and height required by this component when rendered within a given width constraint.

Parameters ​

ParameterType
widthnumber
contextLayoutContext

Returns ​

object

NameType
height
table.ts:171
number
width
table.ts:171
number

Implementation of ​

Component.measure

Released under the MIT License.