Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 165
Forks 15
PowerShell Gallery downloads 158,661
Release v3.0.8
Language: C# Updated: 2026-10-12

API Reference

Cmdlet

Export-OfficeDocumentPdf

Namespace 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.

Remarks

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

Examples

Authored help example

Export a live Word document.

PS>


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

Export a supported file without opening it explicitly.

PS>


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

Configure Markdown PDF export with ordinary PowerShell parameters.

PS>


$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.

PS>


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

Stream selected file outcomes and retain the final summary.

PS>


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

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.

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

Parameters

AllowLegacyImportLoss SwitchParameter optionalposition: namedpipeline: False
Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
Document Object requiredposition: 0pipeline: True (ByValue)
Live Word, Excel, PowerPoint, HTML, Markdown, or RTF document to export. Saved FileInfo and path strings from the pipeline are opened automatically.
ExcelOptions ExcelToPdfOptions optionalposition: namedpipeline: False
Excel-specific PDF options.
HtmlOptions HtmlToPdfOptions optionalposition: namedpipeline: False
HTML-specific PDF rendering options.
MarkdownOptions MarkdownToPdfOptions optionalposition: namedpipeline: False
Markdown-specific PDF options.
MaximumInputBytes Int64 optionalposition: namedpipeline: False
Maximum source bytes for DOC and TXT import.
Open SwitchParameter optionalposition: namedpipeline: Falsealiases: Show
Open the PDF after exporting it.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the saved PDF file.
Password String optionalposition: namedpipeline: False
Password used to open an encrypted Word, Excel, or PowerPoint source file.
Path String requiredposition: 1pipeline: Falsealiases: FilePath, OutputPath
Destination PDF path.
PdfConversionReportVariable String optionalposition: namedpipeline: False
Variable name that receives the structured PDF conversion report.
PdfWarningVariable String optionalposition: namedpipeline: False
Variable name that receives structured PDF conversion warnings.
PowerPointOptions PowerPointToPdfOptions optionalposition: namedpipeline: False
PowerPoint-specific PDF options.
RtfOptions RtfToPdfOptions optionalposition: namedpipeline: False
RTF-specific PDF options.
SourceConversionReportVariable String optionalposition: namedpipeline: False
Variable receiving source-stage reports separately from PDF rendering diagnostics.
TextOptions PdfPlainTextOptions optionalposition: namedpipeline: False
Literal text layout and strict decoding options. Applies only to TXT sources.
WordOptions WordToPdfOptions optionalposition: namedpipeline: False
Word-specific PDF options.

Outputs

System.IO.FileInfo, OfficeIMO.Workflows.OfficeConversionBatchResult, OfficeIMO.Workflows.OfficeConversionBatchItemResult

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

Parameters

AllowLegacyImportLoss SwitchParameter optionalposition: namedpipeline: False
Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
CheckpointDirectory String optionalposition: namedpipeline: False
Optional durable state directory. Completed sources and outputs are hash-verified on restart.
ConflictPolicy String optionalposition: namedpipeline: Falsevalues: 3
Destination conflict policy. Durable checkpoint jobs require Fail.
Possible values: Fail, Rename, Replace
ConversionRouteId String optionalposition: namedpipeline: False
Explicit executable conversion route, for example html-pdf for HTML stored in TXT files. By default the catalog selects each file's PDF route.
ExcelOptions ExcelToPdfOptions optionalposition: namedpipeline: False
Excel-specific PDF options.
HtmlOptions HtmlToPdfOptions optionalposition: namedpipeline: False
HTML-specific PDF rendering options.
InputDirectory String requiredposition: namedpipeline: False
Source directory for mixed-format PDF export. Batch execution requires PowerShell 7.4 or newer.
ItemResults SwitchParameter optionalposition: namedpipeline: False
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.
MarkdownOptions MarkdownToPdfOptions optionalposition: namedpipeline: False
Markdown-specific PDF options.
MaximumConcurrency Int32 optionalposition: namedpipeline: False
Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
MaximumFiles Int32 optionalposition: namedpipeline: False
Maximum discovered or explicitly selected source files.
MaximumInputBytes Int64 optionalposition: namedpipeline: False
Maximum source bytes for DOC and TXT import.
MaximumOutputBytes Int64 optionalposition: namedpipeline: False
Maximum output bytes per document.
NoRecurse SwitchParameter optionalposition: namedpipeline: False
Exclude descendants when selecting a directory.
OutputDirectory String requiredposition: namedpipeline: False
PDF destination directory. Source names retain their extension plus .pdf.
Password String optionalposition: namedpipeline: False
Password used to open an encrypted Word, Excel, or PowerPoint source file.
PowerPointOptions PowerPointToPdfOptions optionalposition: namedpipeline: False
PowerPoint-specific PDF options.
RetryFailed SwitchParameter optionalposition: namedpipeline: False
Retry recorded failures; completed items remain protected.
RtfOptions RtfToPdfOptions optionalposition: namedpipeline: False
RTF-specific PDF options.
SourceExtensions String[] optionalposition: namedpipeline: False
Restrict directory discovery to these source extensions. Other files are reported as skipped.
SummaryVariable String optionalposition: namedpipeline: False
Variable receiving the bounded batch summary, including when ItemResults is selected.
TextOptions PdfPlainTextOptions optionalposition: namedpipeline: False
Literal text layout and strict decoding options. Applies only to TXT sources.
WordOptions WordToPdfOptions optionalposition: namedpipeline: False
Word-specific PDF options.

Outputs

System.IO.FileInfo, OfficeIMO.Workflows.OfficeConversionBatchResult, OfficeIMO.Workflows.OfficeConversionBatchItemResult

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

Parameters

AllowLegacyImportLoss SwitchParameter optionalposition: namedpipeline: False
Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
CheckpointDirectory String optionalposition: namedpipeline: False
Optional durable state directory. Completed sources and outputs are hash-verified on restart.
ConflictPolicy String optionalposition: namedpipeline: Falsevalues: 3
Destination conflict policy. Durable checkpoint jobs require Fail.
Possible values: Fail, Rename, Replace
ConversionRouteId String optionalposition: namedpipeline: False
Explicit executable conversion route, for example html-pdf for HTML stored in TXT files. By default the catalog selects each file's PDF route.
ExcelOptions ExcelToPdfOptions optionalposition: namedpipeline: False
Excel-specific PDF options.
HtmlOptions HtmlToPdfOptions optionalposition: namedpipeline: False
HTML-specific PDF rendering options.
InputPaths Object[] requiredposition: namedpipeline: True (ByValue, ByPropertyName)aliases: SourcePaths
Explicit source paths or FileInfo objects from Get-ChildItem.
ItemResults SwitchParameter optionalposition: namedpipeline: False
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.
MarkdownOptions MarkdownToPdfOptions optionalposition: namedpipeline: False
Markdown-specific PDF options.
MaximumConcurrency Int32 optionalposition: namedpipeline: False
Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
MaximumFiles Int32 optionalposition: namedpipeline: False
Maximum discovered or explicitly selected source files.
MaximumInputBytes Int64 optionalposition: namedpipeline: False
Maximum source bytes for DOC and TXT import.
MaximumOutputBytes Int64 optionalposition: namedpipeline: False
Maximum output bytes per document.
OutputDirectory String requiredposition: namedpipeline: False
PDF destination directory. Source names retain their extension plus .pdf.
Password String optionalposition: namedpipeline: False
Password used to open an encrypted Word, Excel, or PowerPoint source file.
PowerPointOptions PowerPointToPdfOptions optionalposition: namedpipeline: False
PowerPoint-specific PDF options.
RetryFailed SwitchParameter optionalposition: namedpipeline: False
Retry recorded failures; completed items remain protected.
RtfOptions RtfToPdfOptions optionalposition: namedpipeline: False
RTF-specific PDF options.
SummaryVariable String optionalposition: namedpipeline: False
Variable receiving the bounded batch summary, including when ItemResults is selected.
TextOptions PdfPlainTextOptions optionalposition: namedpipeline: False
Literal text layout and strict decoding options. Applies only to TXT sources.
WordOptions WordToPdfOptions optionalposition: namedpipeline: False
Word-specific PDF options.

Outputs

System.IO.FileInfo, OfficeIMO.Workflows.OfficeConversionBatchResult, OfficeIMO.Workflows.OfficeConversionBatchItemResult

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

Parameters

AllowLegacyImportLoss SwitchParameter optionalposition: namedpipeline: False
Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
ExcelOptions ExcelToPdfOptions optionalposition: namedpipeline: False
Excel-specific PDF options.
HtmlOptions HtmlToPdfOptions optionalposition: namedpipeline: False
HTML-specific PDF rendering options.
InputPath String requiredposition: 0pipeline: True (ByPropertyName)aliases: FullName, SourcePath
Source .doc, .docx, .txt, .xlsx, .pptx, .html, .htm, .xhtml, .md, .markdown, or .rtf file.
MarkdownOptions MarkdownToPdfOptions optionalposition: namedpipeline: False
Markdown-specific PDF options.
MaximumInputBytes Int64 optionalposition: namedpipeline: False
Maximum source bytes for DOC and TXT import.
Open SwitchParameter optionalposition: namedpipeline: Falsealiases: Show
Open the PDF after exporting it.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the saved PDF file.
Password String optionalposition: namedpipeline: False
Password used to open an encrypted Word, Excel, or PowerPoint source file.
Path String requiredposition: 1pipeline: Falsealiases: FilePath, OutputPath
Destination PDF path.
PdfConversionReportVariable String optionalposition: namedpipeline: False
Variable name that receives the structured PDF conversion report.
PdfWarningVariable String optionalposition: namedpipeline: False
Variable name that receives structured PDF conversion warnings.
PowerPointOptions PowerPointToPdfOptions optionalposition: namedpipeline: False
PowerPoint-specific PDF options.
RtfOptions RtfToPdfOptions optionalposition: namedpipeline: False
RTF-specific PDF options.
SourceConversionReportVariable String optionalposition: namedpipeline: False
Variable receiving source-stage reports separately from PDF rendering diagnostics.
TextOptions PdfPlainTextOptions optionalposition: namedpipeline: False
Literal text layout and strict decoding options. Applies only to TXT sources.
WordOptions WordToPdfOptions optionalposition: namedpipeline: False
Word-specific PDF options.

Outputs

System.IO.FileInfo, OfficeIMO.Workflows.OfficeConversionBatchResult, OfficeIMO.Workflows.OfficeConversionBatchItemResult