Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficePdf

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

Creates a PDF document using the OfficeIMO.Pdf composition engine.

Syntax

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

Description

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.

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.

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.

Parameters

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

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.