Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficePdf

Module
PSWriteOffice
Inputs
None
Outputs
OfficeIMO.Pdf.PdfDocument System.IO.FileInfo

Creates a live PDF document or atomically saves a completed composition block.

Syntax

New-OfficePdf
[-BoldFontPath <String>]
[-BoldItalicFontPath <String>]
[-CenterWindow]
[-CreateOutlineFromHeadings]
[-DisplayDocTitle]
[-FileVersion <Pdf14|Pdf15|Pdf16|Pdf17|Pdf20>]
[-FitWindow]
[-FlattenVisualAnnotations]
[-Font <String>]
[-FontPath <String>]
[-Force]
[-HideMenubar]
[-HideToolbar]
[-HideWindowUI]
[-IncludePageLabels]
[-ItalicFontPath <String>]
[-OpenActionMode <PdfOpenActionDestinationMode>]
[-OpenActionPage <Int32>]
[-OpenActionTop <Double>]
[-OutlineExpansionLevel <Int32>]
[-OwnerPassword <SecureString>]
[-PageLabelPrefix <String>]
[-PageLayout <PdfCatalogPageLayout>]
[-PageMode <PdfCatalogPageMode>]
[-Password <SecureString>]
[[-Path] <String>]
[-Permission <PdfStandardPermissions>]
[-Size <OfficeLength>]
[-Theme <OfficeThemeInput>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: Live
New-OfficePdf
[-AllowLoss]
[-BoldFontPath <String>]
[-BoldItalicFontPath <String>]
[-CenterWindow]
[-Content] <ScriptBlock>
[-CreateOutlineFromHeadings]
[-DisplayDocTitle]
[-FileVersion <Pdf14|Pdf15|Pdf16|Pdf17|Pdf20>]
[-FitWindow]
[-FlattenVisualAnnotations]
[-Font <String>]
[-FontPath <String>]
[-Force]
[-HideMenubar]
[-HideToolbar]
[-HideWindowUI]
[-IncludePageLabels]
[-ItalicFontPath <String>]
[-OpenActionMode <PdfOpenActionDestinationMode>]
[-OpenActionPage <Int32>]
[-OpenActionTop <Double>]
[-OutlineExpansionLevel <Int32>]
[-OwnerPassword <SecureString>]
[-PageLabelPrefix <String>]
[-PageLayout <PdfCatalogPageLayout>]
[-PageMode <PdfCatalogPageMode>]
[-PassThru]
[-Password <SecureString>]
[-Path] <String>
[-Permission <PdfStandardPermissions>]
[-Show]
[-Size <OfficeLength>]
[-Theme <OfficeThemeInput>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: Content

Description

Without Content no file is written and the native document keeps its optional associated path. A completed block saves and closes; Force is required to replace an existing file.

Examples

Create a themed PDF report.

New-OfficePdf -Path ./Report.pdf -Theme Modern -PassThru {
    PdfHeading 'Service review'
    PdfParagraph 'All services are available.'
}

Create a live document and save it explicitly.

$pdf = New-OfficePdf -Theme Classic -Size 11pt
Add-OfficePdfParagraph -Document $pdf -Text 'Reviewed and approved'
Save-OfficePdf -Document $pdf -Path ./Review.pdf

Parameters

-BoldFontPath String optional
Optional bold face used with FontPath.
-BoldItalicFontPath String optional
Optional bold italic face used with FontPath.
-CenterWindow SwitchParameter optional
Request PDF viewers to center the document window on screen.
-CreateOutlineFromHeadings SwitchParameter optional
Create PDF outline/bookmark entries from heading elements.
-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.
-Font String optional
Body font family; inherited heading defaults follow the document font.
-FontPath String optional
Regular embedded font file; requires the Font family name.
-Force SwitchParameter optional
Allow a completed content block to replace an existing destination.
-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 face used with FontPath.
-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 in the page's native UserUnit space.
-OutlineExpansionLevel Int32 optional
Initial outline expansion level when heading outlines are created.
-OwnerPassword SecureString 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
-Password SecureString optional
Password required to open the generated PDF.
-Path String required in Contentposition: 0aliases: FilePath
Optional associated destination for a live document; required when a content block saves a file.
-Permission PdfStandardPermissions optional
Operations allowed to readers; defaults to all Standard security permissions.
Possible values: Print, ModifyContents, CopyContents, ModifyAnnotations, FillForms, Accessibility, AssembleDocument, HighQualityPrint, All
-Size OfficeLength optional
Default body font size. A bare number means points.
-Theme OfficeThemeInput optional
Built-in theme, theme object or document/template whose visual theme is read.
-WhatIf SwitchParameter optional
Shows what would happen if the command runs.
-Confirm SwitchParameter optional
Prompts for confirmation before running the command.
-AllowLoss SwitchParameter optionalsets: Content
Explicitly accept reductions reported by the content block's native save.
-Content ScriptBlock requiredposition: 1sets: Content
Authoring block to complete before the document is atomically saved and closed.
-PassThru SwitchParameter optionalsets: Content
Return the saved FileInfo after a completed content block.
-Show SwitchParameter optionalsets: Content
Open the saved result in its registered application after the content block succeeds.

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.