Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Export-OfficeDocumentPdf

Module
PSWriteOffice
Inputs
System.Object System.Object[] System.String
Outputs
System.IO.FileInfo OfficeIMO.Workflows.OfficeConversionBatchResult OfficeIMO.Workflows.OfficeConversionBatchItemResult

Exports Word, Excel, PowerPoint, HTML, Markdown, RTF, and literal text documents to PDF.

Syntax

Export-OfficeDocumentPdf
[-AllowLegacyImportLoss]
[-Document] <Object>
[-ExcelOptions <ExcelToPdfOptions>]
[-HtmlOptions <HtmlToPdfOptions>]
[-MarkdownOptions <MarkdownToPdfOptions>]
[-MaximumInputBytes <Int64>]
[-Open]
[-PassThru]
[-Password <String>]
[-Path] <String>
[-PdfConversionReportVariable <String>]
[-PdfWarningVariable <String>]
[-PowerPointOptions <PowerPointToPdfOptions>]
[-RtfOptions <RtfToPdfOptions>]
[-SourceConversionReportVariable <String>]
[-TextOptions <PdfPlainTextOptions>]
[-WordOptions <WordToPdfOptions>]
[<CommonParameters>]
#
Parameter set: Document
Export-OfficeDocumentPdf
[-AllowLegacyImportLoss]
[-CheckpointDirectory <String>]
[-ConflictPolicy <Fail|Rename|Replace>]
[-ConversionRouteId <String>]
[-ExcelOptions <ExcelToPdfOptions>]
[-HtmlOptions <HtmlToPdfOptions>]
-InputDirectory <String>
[-ItemResults]
[-MarkdownOptions <MarkdownToPdfOptions>]
[-MaximumConcurrency <Int32>]
[-MaximumFiles <Int32>]
[-MaximumInputBytes <Int64>]
[-MaximumOutputBytes <Int64>]
[-NoRecurse]
-OutputDirectory <String>
[-Password <String>]
[-PowerPointOptions <PowerPointToPdfOptions>]
[-RetryFailed]
[-RtfOptions <RtfToPdfOptions>]
[-SourceExtensions <String[]>]
[-SummaryVariable <String>]
[-TextOptions <PdfPlainTextOptions>]
[-WordOptions <WordToPdfOptions>]
[<CommonParameters>]
#
Parameter set: Directory
Export-OfficeDocumentPdf
[-AllowLegacyImportLoss]
[-CheckpointDirectory <String>]
[-ConflictPolicy <Fail|Rename|Replace>]
[-ConversionRouteId <String>]
[-ExcelOptions <ExcelToPdfOptions>]
[-HtmlOptions <HtmlToPdfOptions>]
-InputPaths <Object[]>
[-ItemResults]
[-MarkdownOptions <MarkdownToPdfOptions>]
[-MaximumConcurrency <Int32>]
[-MaximumFiles <Int32>]
[-MaximumInputBytes <Int64>]
[-MaximumOutputBytes <Int64>]
-OutputDirectory <String>
[-Password <String>]
[-PowerPointOptions <PowerPointToPdfOptions>]
[-RetryFailed]
[-RtfOptions <RtfToPdfOptions>]
[-SummaryVariable <String>]
[-TextOptions <PdfPlainTextOptions>]
[-WordOptions <WordToPdfOptions>]
[<CommonParameters>]
#
Parameter set: Files
Export-OfficeDocumentPdf
[-AllowLegacyImportLoss]
[-ExcelOptions <ExcelToPdfOptions>]
[-HtmlOptions <HtmlToPdfOptions>]
[-InputPath] <String>
[-MarkdownOptions <MarkdownToPdfOptions>]
[-MaximumInputBytes <Int64>]
[-Open]
[-PassThru]
[-Password <String>]
[-Path] <String>
[-PdfConversionReportVariable <String>]
[-PdfWarningVariable <String>]
[-PowerPointOptions <PowerPointToPdfOptions>]
[-RtfOptions <RtfToPdfOptions>]
[-SourceConversionReportVariable <String>]
[-TextOptions <PdfPlainTextOptions>]
[-WordOptions <WordToPdfOptions>]
[<CommonParameters>]
#
Parameter set: Path

Description

Accepts live OfficeIMO documents, individual files, directories, and selected file pipelines. Directory and file batches require PowerShell 7.4 or newer.

Examples

Export a live Word document.

$document | Export-OfficeDocumentPdf -Path .\Report.pdf

Export a supported file without opening it explicitly.

Export-OfficeDocumentPdf -InputPath .\Report.docx -Path .\Report.pdf -PassThru

Configure Markdown PDF export with ordinary PowerShell parameters.

$options = New-OfficeMarkdownPdfOptions -Title 'Service report' -IncludeLocalImages -BaseDirectory .\Assets
Export-OfficeDocumentPdf -InputPath .\Report.md -Path .\Report.pdf -MarkdownOptions $options

Typed conversion options also apply to the matching formats in a mixed batch.

Export a directory with optional checkpoints.

Export-OfficeDocumentPdf -InputDirectory .\Documents -OutputDirectory .\PDF -CheckpointDirectory .\PDF-State

Stream selected file outcomes and retain the final summary.

Get-ChildItem .\Documents -File | Export-OfficeDocumentPdf -OutputDirectory .\PDF -ItemResults -SummaryVariable summary

Parameters

-AllowLegacyImportLoss SwitchParameter optional
Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
-Document Object requiredposition: 0pipeline: True (ByValue)sets: Document
Live Word, Excel, PowerPoint, HTML, Markdown, or RTF document to export. Saved FileInfo and path strings from the pipeline are opened automatically.
-ExcelOptions ExcelToPdfOptions optional
Excel-specific PDF options.
-HtmlOptions HtmlToPdfOptions optional
HTML-specific PDF rendering options.
-MarkdownOptions MarkdownToPdfOptions optional
Markdown-specific PDF options.
-MaximumInputBytes Int64 optional
Maximum source bytes for DOC and TXT import.
-Open SwitchParameter optionalaliases: Showsets: Document, Path
Open the PDF after exporting it.
-PassThru SwitchParameter optionalsets: Document, Path
Emit the saved PDF file.
-Password String optional
Password used to open an encrypted Word, Excel, or PowerPoint source file.
-Path String requiredposition: 1aliases: FilePath, OutputPathsets: Document, Path
Destination PDF path.
-PdfConversionReportVariable String optionalsets: Document, Path
Variable name that receives the structured PDF conversion report.
-PdfWarningVariable String optionalsets: Document, Path
Variable name that receives structured PDF conversion warnings.
-PowerPointOptions PowerPointToPdfOptions optional
PowerPoint-specific PDF options.
-RtfOptions RtfToPdfOptions optional
RTF-specific PDF options.
-SourceConversionReportVariable String optionalsets: Document, Path
Variable receiving source-stage reports separately from PDF rendering diagnostics.
-TextOptions PdfPlainTextOptions optional
Literal text layout and strict decoding options. Applies only to TXT sources.
-WordOptions WordToPdfOptions optional
Word-specific PDF options.
-CheckpointDirectory String optionalsets: Directory, Files
Optional durable state directory. Completed sources and outputs are hash-verified on restart.
-ConflictPolicy String optionalsets: Directory, Files
Destination conflict policy. Durable checkpoint jobs require Fail.
Possible values: Fail, Rename, Replace
-ConversionRouteId String optionalsets: Directory, Files
Explicit executable conversion route, for example html-pdf for HTML stored in TXT files. By default the catalog selects each file's PDF route.
-InputDirectory String requiredsets: Directory
Source directory for mixed-format PDF export. Batch execution requires PowerShell 7.4 or newer.
-ItemResults SwitchParameter optionalsets: Directory, Files
Stream every structured per-file outcome instead of the final summary. Summary mode reports at most 100 detailed failure warnings and one suppressed-count warning.
-MaximumConcurrency Int32 optionalsets: Directory, Files
Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
-MaximumFiles Int32 optionalsets: Directory, Files
Maximum discovered or explicitly selected source files.
-MaximumOutputBytes Int64 optionalsets: Directory, Files
Maximum output bytes per document.
-NoRecurse SwitchParameter optionalsets: Directory
Exclude descendants when selecting a directory.
-OutputDirectory String requiredsets: Directory, Files
PDF destination directory. Source names retain their extension plus .pdf.
-RetryFailed SwitchParameter optionalsets: Directory, Files
Retry recorded failures; completed items remain protected.
-SourceExtensions String[] optionalsets: Directory
Restrict directory discovery to these source extensions. Other files are reported as skipped.
-SummaryVariable String optionalsets: Directory, Files
Variable receiving the bounded batch summary, including when ItemResults is selected.
-InputPaths Object[] requiredpipeline: True (ByValue, ByPropertyName)aliases: SourcePathssets: Files
Explicit source paths or FileInfo objects from Get-ChildItem.
-InputPath String requiredposition: 0pipeline: True (ByPropertyName)aliases: FullName, SourcePathsets: Path
Source .doc, .docx, .txt, .xlsx, .pptx, .html, .htm, .xhtml, .md, .markdown, or .rtf file.

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.