Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

New-OfficePdf

Aliases: OfficePdf, PdfNew
Namespace PSWriteOffice
Aliases
OfficePdf PdfNew
Inputs
None
Outputs
OfficeIMO.Pdf.PdfDocument System.IO.FileInfo

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

Authored help example

Create a PDF report.

PS>


New-OfficePdf -Path .\Report.pdf { PdfHeading 'Report'; PdfParagraph 'Generated by PSWriteOffice' } -Open
        

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 <Helvetica>] [-DefaultFontSize <Double>] [-DisplayDocTitle] [-FileVersion <Pdf14|Pdf15|Pdf16|Pdf17|Pdf20>] [-FitWindow] [-FlattenVisualAnnotations] [-FontFamily <String>] [-HideMenubar] [-HideToolbar] [-HideWindowUI] [-IncludePageLabels] [-ItalicFontPath <String>] [-NoSave] [-Open] [-OpenActionMode <Xyz>] [-OpenActionPage <Int32>] [-OpenActionTop <Double>] [-OutlineExpansionLevel <Int32>] [-OwnerPassword <String>] [-PageLabelPrefix <String>] [-PageLayout <SinglePage>] [-PageMode <UseNone>] [-PassThru] [-Password <String>] [-Path <String>] [-Permission <Int32>] [-RegularFontPath <String>] [-Theme <WordLike|TechnicalDocument|Compact|Report>] [<CommonParameters>]
#
Parameter set: Path

Parameters

BoldFontPath String optionalposition: namedpipeline: False
Optional bold TrueType font path used when -FontFamily is provided.
BoldItalicFontPath String optionalposition: namedpipeline: False
Optional bold italic TrueType font path used when -FontFamily is provided.
CenterWindow SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to center the document window on screen.
Content ScriptBlock optionalposition: 0pipeline: False
DSL script block describing generated PDF content.
CreateOutlineFromHeadings SwitchParameter optionalposition: namedpipeline: False
Create PDF outline/bookmark entries from heading elements.
DefaultFont PdfStandardFont optionalposition: namedpipeline: Falsevalues: 12
Default standard PDF font for generated text.
Possible values: Helvetica, HelveticaOblique, HelveticaBold, HelveticaBoldOblique, TimesRoman, TimesItalic, TimesBold, TimesBoldItalic, Courier, CourierOblique, CourierBold, CourierBoldOblique
DefaultFontSize Double optionalposition: namedpipeline: False
Default generated text font size in points.
DisplayDocTitle SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to display the document title instead of the file name.
FileVersion PdfFileVersion optionalposition: namedpipeline: Falsevalues: 5
PDF file header version emitted by OfficeIMO.Pdf.
Possible values: Pdf14, Pdf15, Pdf16, Pdf17, Pdf20
FitWindow SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to fit the document window to the first displayed page.
FlattenVisualAnnotations SwitchParameter optionalposition: namedpipeline: False
Flatten generated FreeText and Highlight annotations into static page content.
FontFamily String optionalposition: namedpipeline: False
Embedded TrueType font family name for generated text.
HideMenubar SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide the menu bar.
HideToolbar SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide the toolbar.
HideWindowUI SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide user-interface elements.
IncludePageLabels SwitchParameter optionalposition: namedpipeline: False
Emit generated catalog page labels.
ItalicFontPath String optionalposition: namedpipeline: False
Optional italic TrueType font path used when -FontFamily is provided.
NoSave SwitchParameter optionalposition: namedpipeline: False
Skip saving even when -Path is provided.
Open SwitchParameter optionalposition: namedpipeline: Falsealiases: Show
Open the PDF after saving.
OpenActionMode PdfOpenActionDestinationMode optionalposition: namedpipeline: Falsevalues: 8
Open-action destination mode.
Possible values: Xyz, Fit, FitHorizontal, FitVertical, FitRectangle, FitBoundingBox, FitBoundingBoxHorizontal, FitBoundingBoxVertical
OpenActionPage Int32 optionalposition: namedpipeline: False
Initial one-based page shown by PDF viewers that honor open actions.
OpenActionTop Double optionalposition: namedpipeline: False
Optional open-action top coordinate.
OutlineExpansionLevel Int32 optionalposition: namedpipeline: False
Initial outline expansion level when heading outlines are created.
OwnerPassword String optionalposition: namedpipeline: False
Optional owner password for the generated encrypted PDF.
PageLabelPrefix String optionalposition: namedpipeline: False
Optional generated page-label prefix.
PageLayout PdfCatalogPageLayout optionalposition: namedpipeline: Falsevalues: 6
Catalog page layout hint emitted for generated PDFs.
Possible values: SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight
PageMode PdfCatalogPageMode optionalposition: namedpipeline: Falsevalues: 6
Catalog page mode hint emitted for generated PDFs.
Possible values: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the generated document or saved file for chaining.
Password String optionalposition: namedpipeline: Falsealiases: UserPassword
Password required to open the generated PDF.
Path String optionalposition: 0pipeline: Falsealiases: FilePath
Optional destination PDF path.
Permission Int32 optionalposition: namedpipeline: Falsealiases: Permissions
Raw PDF Standard security permission bit mask. Defaults to allowing all standard operations.
RegularFontPath String optionalposition: namedpipeline: Falsealiases: FontPath
Regular TrueType font path used when -FontFamily is provided.
Theme OfficePdfThemePreset optionalposition: namedpipeline: Falsevalues: 4
Built-in OfficeIMO.Pdf theme applied before the DSL content runs.
Possible values: WordLike, TechnicalDocument, Compact, Report

Outputs

OfficeIMO.Pdf.PdfDocument, System.IO.FileInfo

New-OfficePdf [-BoldFontPath <String>] [-BoldItalicFontPath <String>] [-CenterWindow] [-Content <ScriptBlock>] [-CreateOutlineFromHeadings] [-DefaultFont <Helvetica>] [-DefaultFontSize <Double>] [-DisplayDocTitle] [-FileVersion <Pdf14|Pdf15|Pdf16|Pdf17|Pdf20>] [-FitWindow] [-FlattenVisualAnnotations] [-FontFamily <String>] [-HideMenubar] [-HideToolbar] [-HideWindowUI] [-IncludePageLabels] [-ItalicFontPath <String>] [-NoSave] [-Open] [-OpenActionMode <Xyz>] [-OpenActionPage <Int32>] [-OpenActionTop <Double>] [-OutlineExpansionLevel <Int32>] [-OwnerPassword <String>] [-PageLabelPrefix <String>] [-PageLayout <SinglePage>] [-PageMode <UseNone>] [-PassThru] [-Password <String>] [-Permission <Int32>] [-RegularFontPath <String>] [-Theme <WordLike|TechnicalDocument|Compact|Report>] [<CommonParameters>]
#
Parameter set: Content

Parameters

BoldFontPath String optionalposition: namedpipeline: False
Optional bold TrueType font path used when -FontFamily is provided.
BoldItalicFontPath String optionalposition: namedpipeline: False
Optional bold italic TrueType font path used when -FontFamily is provided.
CenterWindow SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to center the document window on screen.
Content ScriptBlock optionalposition: 0pipeline: False
DSL script block describing generated PDF content.
CreateOutlineFromHeadings SwitchParameter optionalposition: namedpipeline: False
Create PDF outline/bookmark entries from heading elements.
DefaultFont PdfStandardFont optionalposition: namedpipeline: Falsevalues: 12
Default standard PDF font for generated text.
Possible values: Helvetica, HelveticaOblique, HelveticaBold, HelveticaBoldOblique, TimesRoman, TimesItalic, TimesBold, TimesBoldItalic, Courier, CourierOblique, CourierBold, CourierBoldOblique
DefaultFontSize Double optionalposition: namedpipeline: False
Default generated text font size in points.
DisplayDocTitle SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to display the document title instead of the file name.
FileVersion PdfFileVersion optionalposition: namedpipeline: Falsevalues: 5
PDF file header version emitted by OfficeIMO.Pdf.
Possible values: Pdf14, Pdf15, Pdf16, Pdf17, Pdf20
FitWindow SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to fit the document window to the first displayed page.
FlattenVisualAnnotations SwitchParameter optionalposition: namedpipeline: False
Flatten generated FreeText and Highlight annotations into static page content.
FontFamily String optionalposition: namedpipeline: False
Embedded TrueType font family name for generated text.
HideMenubar SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide the menu bar.
HideToolbar SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide the toolbar.
HideWindowUI SwitchParameter optionalposition: namedpipeline: False
Request PDF viewers to hide user-interface elements.
IncludePageLabels SwitchParameter optionalposition: namedpipeline: False
Emit generated catalog page labels.
ItalicFontPath String optionalposition: namedpipeline: False
Optional italic TrueType font path used when -FontFamily is provided.
NoSave SwitchParameter optionalposition: namedpipeline: False
Skip saving even when -Path is provided.
Open SwitchParameter optionalposition: namedpipeline: Falsealiases: Show
Open the PDF after saving.
OpenActionMode PdfOpenActionDestinationMode optionalposition: namedpipeline: Falsevalues: 8
Open-action destination mode.
Possible values: Xyz, Fit, FitHorizontal, FitVertical, FitRectangle, FitBoundingBox, FitBoundingBoxHorizontal, FitBoundingBoxVertical
OpenActionPage Int32 optionalposition: namedpipeline: False
Initial one-based page shown by PDF viewers that honor open actions.
OpenActionTop Double optionalposition: namedpipeline: False
Optional open-action top coordinate.
OutlineExpansionLevel Int32 optionalposition: namedpipeline: False
Initial outline expansion level when heading outlines are created.
OwnerPassword String optionalposition: namedpipeline: False
Optional owner password for the generated encrypted PDF.
PageLabelPrefix String optionalposition: namedpipeline: False
Optional generated page-label prefix.
PageLayout PdfCatalogPageLayout optionalposition: namedpipeline: Falsevalues: 6
Catalog page layout hint emitted for generated PDFs.
Possible values: SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight
PageMode PdfCatalogPageMode optionalposition: namedpipeline: Falsevalues: 6
Catalog page mode hint emitted for generated PDFs.
Possible values: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the generated document or saved file for chaining.
Password String optionalposition: namedpipeline: Falsealiases: UserPassword
Password required to open the generated PDF.
Permission Int32 optionalposition: namedpipeline: Falsealiases: Permissions
Raw PDF Standard security permission bit mask. Defaults to allowing all standard operations.
RegularFontPath String optionalposition: namedpipeline: Falsealiases: FontPath
Regular TrueType font path used when -FontFamily is provided.
Theme OfficePdfThemePreset optionalposition: namedpipeline: Falsevalues: 4
Built-in OfficeIMO.Pdf theme applied before the DSL content runs.
Possible values: WordLike, TechnicalDocument, Compact, Report

Outputs

OfficeIMO.Pdf.PdfDocument, System.IO.FileInfo