Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficePdfTable

Aliases: PdfTable
Module
PSWriteOffice
Aliases
PdfTable
Inputs
OfficeIMO.Pdf.PdfDocument System.Object[]
Outputs
OfficeIMO.Pdf.PdfDocument

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>]
#
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>]
#
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>]
#
Parameter set: PipelineDocument

Examples

Add object data as a PDF table.

$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.

$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.