# New-OfficePdf

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

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`None`

**Outputs**

`OfficeIMO.Pdf.PdfDocument` `System.IO.FileInfo`

**Source**

[NewOfficePdfCommand.cs:23](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Pdf/NewOfficePdfCommand.cs#L23) 

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>]
```

[#](#member-08443c2bfb2a29723213fed1)

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>]
```

[#](#member-850a0d6b2b65485e7ba79d64)

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.

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [PSWriteOffice DSL Cookbook](/docs/pswriteoffice/dsl-cookbook/) Guide
  
  Copy complete PowerShell recipes for Word, Excel, PowerPoint, PDF, Markdown, and multi-format document jobs.
- [Choose a PSWriteOffice Workflow](/docs/pswriteoffice/choosing-a-workflow/) Guide
  
  Decide between authoring, editing, inspection, conversion, and normalized Reader extraction. Includes examples and cmdlet links.
- [Migrate from PSWritePDF to PSWriteOffice](/docs/pswriteoffice/migrate-from-pswritepdf/) Guide
  
  Replace legacy PSWritePDF and iText-based scripts with maintained OfficeIMO PDF commands for authoring, extraction, forms, and merge.
- [Automate PDF Workflows](/docs/pswriteoffice/pdf/) Guide
  
  Author, inspect, combine, annotate, sign, preflight, optimize, redact, and extract PDF files. Includes examples and cmdlet links.
- [PowerShell Document Recipes](/docs/workflows/powershell-recipes/) Guide
  
  Practical PSWriteOffice patterns for reports, presentations, PDF, CSV, Markdown, RTF, and document extraction. Includes examples and API links.
- [Fill and Flatten PDF Forms](/docs/pdf/forms/) Guide
  
  List AcroForm fields, fill them by name, flatten the result, exchange XFDF data, and add form fields to new PDFs with OfficeIMO.Pdf and PSWriteOffice.

## Examples

### Create a themed PDF report.

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

### Create a live document and save it explicitly.

```powershell
$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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:335867131B94BB146D001B7A4B025DD5462730A20F97BB2294B066185DD60224 -->
