API Reference

Cmdlet

New-OfficePdf

Aliases: PdfNew
Namespace PSWriteOffice
Aliases
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' } -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>]
#
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 Nullable`1 optionalposition: namedpipeline: False
Default standard PDF font for generated text.
DefaultFontSize Nullable`1 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 Nullable`1 optionalposition: namedpipeline: False
PDF file header version emitted by OfficeIMO.Pdf.
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.
OpenActionMode Nullable`1 optionalposition: namedpipeline: False
Open-action destination mode.
OpenActionPage Nullable`1 optionalposition: namedpipeline: False
Initial one-based page shown by PDF viewers that honor open actions.
OpenActionTop Nullable`1 optionalposition: namedpipeline: False
Optional open-action top coordinate.
OutlineExpansionLevel Nullable`1 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 Nullable`1 optionalposition: namedpipeline: False
Catalog page layout hint emitted for generated PDFs.
PageMode Nullable`1 optionalposition: namedpipeline: False
Catalog page mode hint emitted for generated PDFs.
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 Nullable`1 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.
Show SwitchParameter optionalposition: namedpipeline: False
Open the PDF after saving.
Theme Nullable`1 optionalposition: namedpipeline: False
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>]
#
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 Nullable`1 optionalposition: namedpipeline: False
Default standard PDF font for generated text.
DefaultFontSize Nullable`1 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 Nullable`1 optionalposition: namedpipeline: False
PDF file header version emitted by OfficeIMO.Pdf.
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.
OpenActionMode Nullable`1 optionalposition: namedpipeline: False
Open-action destination mode.
OpenActionPage Nullable`1 optionalposition: namedpipeline: False
Initial one-based page shown by PDF viewers that honor open actions.
OpenActionTop Nullable`1 optionalposition: namedpipeline: False
Optional open-action top coordinate.
OutlineExpansionLevel Nullable`1 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 Nullable`1 optionalposition: namedpipeline: False
Catalog page layout hint emitted for generated PDFs.
PageMode Nullable`1 optionalposition: namedpipeline: False
Catalog page mode hint emitted for generated PDFs.
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 Nullable`1 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.
Show SwitchParameter optionalposition: namedpipeline: False
Open the PDF after saving.
Theme Nullable`1 optionalposition: namedpipeline: False
Built-in OfficeIMO.Pdf theme applied before the DSL content runs.

Outputs

OfficeIMO.Pdf.PdfDocument System.IO.FileInfo