API Reference
New-OfficePdf
Creates a PDF document using the OfficeIMO.Pdf composition engine.
Remarks
New-OfficePdf starts a generated PDF document and optionally executes a PSWriteOffice PDF DSL script block. The DSL commands are thin adapters over OfficeIMO.Pdf and support document metadata, page setup, headers, footers, themes, styled text, tables, panels, row layouts, form fields, attachments, compliance settings, and save/open behavior. Use -NoSave or omit -Path when a document object should be returned for further pipeline operations.
Examples
Create a PDF report.
PS>
New-OfficePdf -Path .\Report.pdf { PdfHeading 'Report'; PdfParagraph 'Generated by PSWriteOffice' } -Show
Builds a PDF and opens it after saving.
Create a polished report with theme, metadata, and layout.
PS>
New-OfficePdf -Path .\ServiceReview.pdf {
PdfTheme Report
PdfMetadata -Title 'Service Review' -Author 'PSWriteOffice'
PdfPageSetup -PageSize A4 -Margin 42
PdfHeader 'Service Review'
PdfFooter 'Page {page}/{pages}'
PdfHeading 'Service Review'
PdfText -Run @(
@{ Text = 'Generated with ' }
@{ Text = 'rich inline text'; Bold = $true; Color = '#0F766E' }
@{ Text = ' and OfficeIMO.Pdf layout.' }
)
PdfRow -Column @(
@{ Width = 40; Content = @(@{ Type = 'Panel'; Text = 'Left summary' }) }
@{ Width = 60; Content = @(@{ Type = 'Paragraph'; Text = 'Right details' }) }
)
}
Shows the preferred high-level PDF report authoring shape.
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.
Syntax
New-OfficePdf [-BoldFontPath <String>] [-BoldItalicFontPath <String>] [-CenterWindow] [-Content <ScriptBlock>] [-CreateOutlineFromHeadings] [-DefaultFont <Nullable`1>] [-DefaultFontSize <Nullable`1>] [-DisplayDocTitle] [-FileVersion <Nullable`1>] [-FitWindow] [-FlattenVisualAnnotations] [-FontFamily <String>] [-HideMenubar] [-HideToolbar] [-HideWindowUI] [-IncludePageLabels] [-ItalicFontPath <String>] [-NoSave] [-OpenActionMode <Nullable`1>] [-OpenActionPage <Nullable`1>] [-OpenActionTop <Nullable`1>] [-OutlineExpansionLevel <Nullable`1>] [-OwnerPassword <String>] [-PageLabelPrefix <String>] [-PageLayout <Nullable`1>] [-PageMode <Nullable`1>] [-PassThru] [-Password <String>] [-Path <String>] [-Permission <Nullable`1>] [-RegularFontPath <String>] [-Show] [-Theme <Nullable`1>] [<CommonParameters>]#PathParameters
- BoldFontPath String
- Optional bold TrueType font path used when -FontFamily is provided.
- BoldItalicFontPath String
- Optional bold italic TrueType font path used when -FontFamily is provided.
- CenterWindow SwitchParameter
- Request PDF viewers to center the document window on screen.
- Content ScriptBlock
- DSL script block describing generated PDF content.
- CreateOutlineFromHeadings SwitchParameter
- Create PDF outline/bookmark entries from heading elements.
- DefaultFont Nullable`1
- Default standard PDF font for generated text.
- DefaultFontSize Nullable`1
- Default generated text font size in points.
- DisplayDocTitle SwitchParameter
- Request PDF viewers to display the document title instead of the file name.
- FileVersion Nullable`1
- PDF file header version emitted by OfficeIMO.Pdf.
- FitWindow SwitchParameter
- Request PDF viewers to fit the document window to the first displayed page.
- FlattenVisualAnnotations SwitchParameter
- Flatten generated FreeText and Highlight annotations into static page content.
- FontFamily String
- Embedded TrueType font family name for generated text.
- HideMenubar SwitchParameter
- Request PDF viewers to hide the menu bar.
- HideToolbar SwitchParameter
- Request PDF viewers to hide the toolbar.
- HideWindowUI SwitchParameter
- Request PDF viewers to hide user-interface elements.
- IncludePageLabels SwitchParameter
- Emit generated catalog page labels.
- ItalicFontPath String
- Optional italic TrueType font path used when -FontFamily is provided.
- NoSave SwitchParameter
- Skip saving even when -Path is provided.
- OpenActionMode Nullable`1
- Open-action destination mode.
- OpenActionPage Nullable`1
- Initial one-based page shown by PDF viewers that honor open actions.
- OpenActionTop Nullable`1
- Optional open-action top coordinate.
- OutlineExpansionLevel Nullable`1
- Initial outline expansion level when heading outlines are created.
- OwnerPassword String
- Optional owner password for the generated encrypted PDF.
- PageLabelPrefix String
- Optional generated page-label prefix.
- PageLayout Nullable`1
- Catalog page layout hint emitted for generated PDFs.
- PageMode Nullable`1
- Catalog page mode hint emitted for generated PDFs.
- PassThru SwitchParameter
- Emit the generated document or saved file for chaining.
- Password String
- Password required to open the generated PDF.
- Path String
- Optional destination PDF path.
- Permission Nullable`1
- Raw PDF Standard security permission bit mask. Defaults to allowing all standard operations.
- RegularFontPath String
- Regular TrueType font path used when -FontFamily is provided.
- Show SwitchParameter
- Open the PDF after saving.
- Theme Nullable`1
- Built-in OfficeIMO.Pdf theme applied before the DSL content runs.
Outputs
OfficeIMO.Pdf.PdfDocument System.IO.FileInfo
New-OfficePdf [-BoldFontPath <String>] [-BoldItalicFontPath <String>] [-CenterWindow] [-Content <ScriptBlock>] [-CreateOutlineFromHeadings] [-DefaultFont <Nullable`1>] [-DefaultFontSize <Nullable`1>] [-DisplayDocTitle] [-FileVersion <Nullable`1>] [-FitWindow] [-FlattenVisualAnnotations] [-FontFamily <String>] [-HideMenubar] [-HideToolbar] [-HideWindowUI] [-IncludePageLabels] [-ItalicFontPath <String>] [-NoSave] [-OpenActionMode <Nullable`1>] [-OpenActionPage <Nullable`1>] [-OpenActionTop <Nullable`1>] [-OutlineExpansionLevel <Nullable`1>] [-OwnerPassword <String>] [-PageLabelPrefix <String>] [-PageLayout <Nullable`1>] [-PageMode <Nullable`1>] [-PassThru] [-Password <String>] [-Permission <Nullable`1>] [-RegularFontPath <String>] [-Show] [-Theme <Nullable`1>] [<CommonParameters>]#ContentParameters
- BoldFontPath String
- Optional bold TrueType font path used when -FontFamily is provided.
- BoldItalicFontPath String
- Optional bold italic TrueType font path used when -FontFamily is provided.
- CenterWindow SwitchParameter
- Request PDF viewers to center the document window on screen.
- Content ScriptBlock
- DSL script block describing generated PDF content.
- CreateOutlineFromHeadings SwitchParameter
- Create PDF outline/bookmark entries from heading elements.
- DefaultFont Nullable`1
- Default standard PDF font for generated text.
- DefaultFontSize Nullable`1
- Default generated text font size in points.
- DisplayDocTitle SwitchParameter
- Request PDF viewers to display the document title instead of the file name.
- FileVersion Nullable`1
- PDF file header version emitted by OfficeIMO.Pdf.
- FitWindow SwitchParameter
- Request PDF viewers to fit the document window to the first displayed page.
- FlattenVisualAnnotations SwitchParameter
- Flatten generated FreeText and Highlight annotations into static page content.
- FontFamily String
- Embedded TrueType font family name for generated text.
- HideMenubar SwitchParameter
- Request PDF viewers to hide the menu bar.
- HideToolbar SwitchParameter
- Request PDF viewers to hide the toolbar.
- HideWindowUI SwitchParameter
- Request PDF viewers to hide user-interface elements.
- IncludePageLabels SwitchParameter
- Emit generated catalog page labels.
- ItalicFontPath String
- Optional italic TrueType font path used when -FontFamily is provided.
- NoSave SwitchParameter
- Skip saving even when -Path is provided.
- OpenActionMode Nullable`1
- Open-action destination mode.
- OpenActionPage Nullable`1
- Initial one-based page shown by PDF viewers that honor open actions.
- OpenActionTop Nullable`1
- Optional open-action top coordinate.
- OutlineExpansionLevel Nullable`1
- Initial outline expansion level when heading outlines are created.
- OwnerPassword String
- Optional owner password for the generated encrypted PDF.
- PageLabelPrefix String
- Optional generated page-label prefix.
- PageLayout Nullable`1
- Catalog page layout hint emitted for generated PDFs.
- PageMode Nullable`1
- Catalog page mode hint emitted for generated PDFs.
- PassThru SwitchParameter
- Emit the generated document or saved file for chaining.
- Password String
- Password required to open the generated PDF.
- Permission Nullable`1
- Raw PDF Standard security permission bit mask. Defaults to allowing all standard operations.
- RegularFontPath String
- Regular TrueType font path used when -FontFamily is provided.
- Show SwitchParameter
- Open the PDF after saving.
- Theme Nullable`1
- Built-in OfficeIMO.Pdf theme applied before the DSL content runs.
Outputs
OfficeIMO.Pdf.PdfDocument System.IO.FileInfo