# Add-OfficePdfTable

Adds a table to a PDF document. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice Cmdlet Reference.

Cmdlet 

Aliases: PdfTable

**Module**

`PSWriteOffice`

**Aliases**

`PdfTable`

**Inputs**

`OfficeIMO.Pdf.PdfDocument` `System.Object[]`

**Outputs**

`OfficeIMO.Pdf.PdfDocument`

**Source**

[AddOfficePdfTableCommand.cs:45](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Pdf/AddOfficePdfTableCommand.cs#L45) 

Adds a table to a PDF document.

## Syntax

```
Add-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal|Transpose>]
[<CommonParameters>]
```

[#](#member-c37d0b40e4a4e134c027ee57)

Parameter set: `Context`

```
Add-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
-Document <PdfDocument>
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-PassThru]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal|Transpose>]
[<CommonParameters>]
```

[#](#member-a29c8e55a0d6a4f4695c5c21)

Parameter set: `Document`

```
Add-OfficePdfTable
[-Alignment <OfficeAlignment>]
[-AutoFit]
[-BandColor <OfficeColor>]
[-BorderColor <OfficeColor>]
[-BorderWidth <OfficeLength>]
[-Caption <String>]
[-CaptionAlignment <OfficeAlignment>]
[-CaptionColor <OfficeColor>]
[-CaptionSize <OfficeLength>]
[-CellPaddingX <OfficeLength>]
[-CellPaddingY <OfficeLength>]
[-CollectionSeparator <String>]
[-Color <OfficeColor>]
[-ColumnAlignment <OfficeAlignment[]>]
[-ColumnFormat <Hashtable>]
[-ColumnWeight <Double[]>]
[-ColumnWidth <OfficeLength[]>]
[-DictionaryEntrySeparator <String>]
[-DictionaryKeyValueSeparator <String>]
-Document <PdfDocument>
[-FooterRowCount <Int32>]
[-Header <String[]>]
[-HeaderBackgroundColor <OfficeColor>]
[-HeaderColor <OfficeColor>]
[-HeaderRowCount <Int32>]
[-HeaderSize <OfficeLength>]
[-InputObject] <Object[]>
[-KeepTogether]
[-KeepWithNext]
[-LineHeight <Double>]
[-MaxCollectionItems <Int32>]
[-MaxNestingDepth <Int32>]
[-MinimumSize <OfficeLength>]
[-NoBanding]
[-NoBorder]
[-NoHeaderBackground]
[-NoNumericAlignment]
[-PageSummary <PdfTablePageSummary>]
[-PassThru]
[-Property <String[]>]
[-RepeatFooterRows]
[-RepeatHeaderRowCount <Int32>]
[-ShrinkToFit]
[-Size <OfficeLength>]
[-SpacingAfter <OfficeLength>]
[-SpacingBefore <OfficeLength>]
[-TableStyle <String>]
[-View <Normal|Transpose>]
[<CommonParameters>]
```

[#](#member-0323d3143c4e75e8dbc07352)

Parameter set: `PipelineDocument`

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [PSWriteOffice DSL Cookbook](/docs/pswriteoffice/dsl-cookbook/) Guide
  
  Copy complete PowerShell recipes for Word, Excel, PowerPoint, PDF, Markdown, and multi-format document jobs.
- [Migrate from PSWritePDF to PSWriteOffice](/docs/pswriteoffice/migrate-from-pswritepdf/) Guide
  
  Replace legacy PSWritePDF and iText-based scripts with maintained OfficeIMO PDF commands for authoring, extraction, forms, and merge.
- [Pipeline, Object, and DSL Workflows](/docs/pswriteoffice/object-workflows/) Guide
  
  Choose the shortest PSWriteOffice surface for quick exports, incremental composition, complete document authoring, or existing-file updates.
- [PDF Quick Start](/docs/pdf/quick-start/) Guide
  
  Create a PDF with headings, paragraphs, a table, and an image, then load it and read its text, with OfficeIMO.Pdf, PSWriteOffice, or the officeimo CLI.

## Examples

### Add object data as a PDF table.

```powershell
$services = @(
    [pscustomobject]@{ Name = 'Directory'; Status = 'Healthy'; Incidents = 0 }
    [pscustomobject]@{ Name = 'Mail'; Status = 'Watch'; Incidents = 2 }
)
New-OfficePdf -Path .\Examples\Documents\PdfTable.pdf {
    Add-OfficePdfHeading -Text 'Service status'
    Add-OfficePdfTable -InputObject $services -Property Name,Status,Incidents -Header 'Service','Status','Incidents'
}
```

Converts PowerShell objects into a table using selected properties and friendly headers.

### Carry invoice amounts across pages.

```powershell
$summary = [OfficeIMO.Pdf.PdfTablePageSummary]::new()
$amount = $summary.Sum('amount', 2, 'N2', $null)
$null = $summary.AddContinuationHeaderRow([string[]] @('Brought forward', '', $amount.BroughtForwardToken))
$null = $summary.AddPageFooterRow([string[]] @('Carried forward', '', $amount.RunningToken))
$lines = 1..120 | ForEach-Object { [pscustomobject]@{ Item = $_; Description = 'Consulting hour'; Amount = '125.00' } }
$lines += [pscustomobject]@{ Item = 'Total'; Description = ''; Amount = $amount.RunningToken }
New-OfficePdf -Path .\Examples\Documents\PdfInvoiceLines.pdf {
    Add-OfficePdfTable -InputObject $lines -FooterRowCount 1 -PageSummary $summary
}
```

Each page that continues ends with the running amount, and the next page starts with the amount brought forward.

## Parameters

**-Alignment OfficeAlignment optional**

Table alignment.

Possible values: `Left`, `Center`, `Right`, `Justify`, `Start`, `End`

**-AutoFit SwitchParameter optional**

Measure flexible columns from content.

**-BandColor OfficeColor optional**

Alternating body row fill color. Named colors and hexadecimal values are accepted.

**-BorderColor OfficeColor optional**

Border color. Named colors and hexadecimal values are accepted.

**-BorderWidth OfficeLength optional**

Border width in PDF points.

**-Caption String optional**

Caption rendered above the table grid.

**-CaptionAlignment OfficeAlignment optional**

Caption alignment.

Possible values: `Left`, `Center`, `Right`, `Justify`, `Start`, `End`

**-CaptionColor OfficeColor optional**

Caption color. Named colors and hexadecimal values are accepted.

**-CaptionSize OfficeLength optional**

Caption font size in PDF points.

**-CellPaddingX OfficeLength optional**

Horizontal cell padding in PDF points.

**-CellPaddingY OfficeLength optional**

Vertical cell padding in PDF points.

**-CollectionSeparator String optional**

Text used between items when a property or cell contains a collection.

**-Color OfficeColor optional**

Body text color. Named colors and hexadecimal values are accepted.

**-ColumnAlignment OfficeAlignment[] optional**

Per-column horizontal alignment.

Possible values: `Left`, `Center`, `Right`, `Justify`, `Start`, `End`

**-ColumnFormat Hashtable optional**

Invariant .NET display formats keyed by selected property name.

**-ColumnWeight Double[] optional**

Relative column width weights.

**-ColumnWidth OfficeLength[] optional**

Fixed column widths in PDF points.

**-DictionaryEntrySeparator String optional**

Text used between entries when a cell contains a dictionary.

**-DictionaryKeyValueSeparator String optional**

Text used between a dictionary key and value.

**-FooterRowCount Int32 optional**

Number of trailing rows rendered as footer rows.

**-Header String[] optional**

Header labels. Defaults to property names.

**-HeaderBackgroundColor OfficeColor optional**

Header fill color. Named colors and hexadecimal values are accepted.

**-HeaderColor OfficeColor optional**

Header text color. Named colors and hexadecimal values are accepted.

**-HeaderRowCount Int32 optional**

Number of leading rows rendered as header rows.

**-HeaderSize OfficeLength optional**

Header cell font size in PDF points.

**-InputObject Object[] requiredposition: 0pipeline: True (ByValue)**

Objects or row arrays to render as a table.

**-KeepTogether SwitchParameter optional**

Keep the table together when possible.

**-KeepWithNext SwitchParameter optional**

Keep the table with the next block when possible.

**-LineHeight Double optional**

Wrapped line height multiplier for table cells.

**-MaxCollectionItems Int32 optional**

Maximum number of items allowed in one nested collection or dictionary cell. Defaults to 1,048,575; increase explicitly for trusted larger values.

**-MaxNestingDepth Int32 optional**

Maximum nesting depth allowed while normalizing one cell value. Defaults to 64; increase explicitly for trusted deeper values.

**-MinimumSize OfficeLength optional**

Smallest font size, in points, used by -ShrinkToFit.

**-NoBanding SwitchParameter optional**

Disable alternating row fill.

**-NoBorder SwitchParameter optional**

Hide table borders.

**-NoHeaderBackground SwitchParameter optional**

Disable the header fill.

**-NoNumericAlignment SwitchParameter optional**

Right-align numeric-looking cell values.

**-PageSummary PdfTablePageSummary optional**

Per-page aggregates and summary rows, such as page subtotals and carried-forward or brought-forward amounts. Footer rows and summary rows can show aggregate tokens such as {page:amount}, {broughtForward:amount} and {running:amount}.

**-Property String[] optional**

Specific object properties to include.

**-RepeatFooterRows SwitchParameter optional**

Close every page of a table that continues across pages with its footer rows, not only the last page.

**-RepeatHeaderRowCount Int32 optional**

Number of leading header rows repeated on following pages.

**-ShrinkToFit SwitchParameter optional**

Reduce table text size when needed so cell text fits within the resolved cell width.

**-Size OfficeLength optional**

Body cell font size in PDF points.

**-SpacingAfter OfficeLength optional**

Spacing after the table in PDF points.

**-SpacingBefore OfficeLength optional**

Spacing before the table in PDF points.

**-TableStyle String optional**

OfficeIMO table style preset or supported Word table style name.

**-View OfficeTableView optional**

Projection to apply before writing the table.

Possible values: `Normal`, `Transpose`

**-Document PdfDocument requiredpipeline: True (ByValue)sets: Document, PipelineDocument**

PDF document to update outside the DSL context.

**-PassThru SwitchParameter optionalsets: Document, PipelineDocument**

Emit the updated document.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:1D09A73E8502A4933DF723BBD5A76D27323E783FBBD0C4E40FEBAA09C8173306 -->
