Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Save-OfficePdf

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

Saves a live PDF to its associated path or a new destination without closing it.

Syntax

Save-OfficePdf
[-AllowLoss]
-Document <PdfDocument>
[-OwnerPassword <SecureString>]
[-PassThru]
[-Password <SecureString>]
[[-Path] <String>]
[-Permission <PdfStandardPermissions>]
[-Show]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
Parameter set: Document

Description

Native serialization rejects content loss unless AllowLoss is supplied. Password and OwnerPassword accept shared secure input. Security options encrypt an unencrypted output; use Protect-OfficeDocument for security changes to an already protected file.

Examples

Save to the associated destination and keep editing.

$pdf = New-OfficePdf -Path ./Review.pdf
Add-OfficePdfParagraph -Document $pdf -Text 'Reviewed and approved'
$pdf | Save-OfficePdf -PassThru
Close-OfficePdf -Document $pdf

Restrict printing and accessibility without requiring an opening password.

$owner = Read-Host -AsSecureString
Save-OfficePdf -Document $pdf -Path ./Restricted.pdf -OwnerPassword $owner -Permission Print,Accessibility

Parameters

-AllowLoss SwitchParameter optional
Explicitly accept fidelity loss from native PDF serialization.
-Document PdfDocument requiredpipeline: True (ByValue)
Live PDF to save.
-OwnerPassword SecureString optional
Owner password; without Password the PDF opens without a password and enforces permissions.
-PassThru SwitchParameter optional
Return the saved FileInfo.
-Password SecureString optional
Opening password for an unencrypted output; accepts secure input or warned plaintext.
-Path String optionalposition: 0
Optional destination; omission uses the native document's associated path.
-Permission PdfStandardPermissions optional
Operations allowed to readers, expressed as native PDF permission flags.
Possible values: Print, ModifyContents, CopyContents, ModifyAnnotations, FillForms, Accessibility, AssembleDocument, HighQualityPrint, All
-Show SwitchParameter optional
Open the saved file in its registered default application.
-WhatIf SwitchParameter optional
Shows what would happen if the command runs.
-Confirm SwitchParameter optional
Prompts for confirmation before running the command.

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.