API Reference
Export-OfficeDocumentPdf
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
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>]#DocumentParameters
- AllowLegacyImportLoss SwitchParameter
- Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
- Document Object
- Live Word, Excel, PowerPoint, HTML, Markdown, or RTF document to export. Saved FileInfo and path strings from the pipeline are opened automatically.
- ExcelOptions ExcelToPdfOptions
- Excel-specific PDF options.
- HtmlOptions HtmlToPdfOptions
- HTML-specific PDF rendering options.
- MarkdownOptions MarkdownToPdfOptions
- Markdown-specific PDF options.
- MaximumInputBytes Int64
- Maximum source bytes for DOC and TXT import.
- Open SwitchParameter
- Open the PDF after exporting it.
- PassThru SwitchParameter
- Emit the saved PDF file.
- Password String
- Password used to open an encrypted Word, Excel, or PowerPoint source file.
- Path String
- Destination PDF path.
- PdfConversionReportVariable String
- Variable name that receives the structured PDF conversion report.
- PdfWarningVariable String
- Variable name that receives structured PDF conversion warnings.
- PowerPointOptions PowerPointToPdfOptions
- PowerPoint-specific PDF options.
- RtfOptions RtfToPdfOptions
- RTF-specific PDF options.
- SourceConversionReportVariable String
- Variable receiving source-stage reports separately from PDF rendering diagnostics.
- TextOptions PdfPlainTextOptions
- Literal text layout and strict decoding options. Applies only to TXT sources.
- WordOptions WordToPdfOptions
- 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>]#DirectoryParameters
- AllowLegacyImportLoss SwitchParameter
- Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
- CheckpointDirectory String
- Optional durable state directory. Completed sources and outputs are hash-verified on restart.
- ConflictPolicy String
- Destination conflict policy. Durable checkpoint jobs require Fail.
- Possible values:
Fail,Rename,Replace - ConversionRouteId String
- 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
- Excel-specific PDF options.
- HtmlOptions HtmlToPdfOptions
- HTML-specific PDF rendering options.
- InputDirectory String
- Source directory for mixed-format PDF export. Batch execution requires PowerShell 7.4 or newer.
- ItemResults SwitchParameter
- 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
- Markdown-specific PDF options.
- MaximumConcurrency Int32
- Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
- MaximumFiles Int32
- Maximum discovered or explicitly selected source files.
- MaximumInputBytes Int64
- Maximum source bytes for DOC and TXT import.
- MaximumOutputBytes Int64
- Maximum output bytes per document.
- NoRecurse SwitchParameter
- Exclude descendants when selecting a directory.
- OutputDirectory String
- PDF destination directory. Source names retain their extension plus .pdf.
- Password String
- Password used to open an encrypted Word, Excel, or PowerPoint source file.
- PowerPointOptions PowerPointToPdfOptions
- PowerPoint-specific PDF options.
- RetryFailed SwitchParameter
- Retry recorded failures; completed items remain protected.
- RtfOptions RtfToPdfOptions
- RTF-specific PDF options.
- SourceExtensions String[]
- Restrict directory discovery to these source extensions. Other files are reported as skipped.
- SummaryVariable String
- Variable receiving the bounded batch summary, including when ItemResults is selected.
- TextOptions PdfPlainTextOptions
- Literal text layout and strict decoding options. Applies only to TXT sources.
- WordOptions WordToPdfOptions
- 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>]#FilesParameters
- AllowLegacyImportLoss SwitchParameter
- Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
- CheckpointDirectory String
- Optional durable state directory. Completed sources and outputs are hash-verified on restart.
- ConflictPolicy String
- Destination conflict policy. Durable checkpoint jobs require Fail.
- Possible values:
Fail,Rename,Replace - ConversionRouteId String
- 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
- Excel-specific PDF options.
- HtmlOptions HtmlToPdfOptions
- HTML-specific PDF rendering options.
- InputPaths Object[]
- Explicit source paths or FileInfo objects from Get-ChildItem.
- ItemResults SwitchParameter
- 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
- Markdown-specific PDF options.
- MaximumConcurrency Int32
- Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
- MaximumFiles Int32
- Maximum discovered or explicitly selected source files.
- MaximumInputBytes Int64
- Maximum source bytes for DOC and TXT import.
- MaximumOutputBytes Int64
- Maximum output bytes per document.
- OutputDirectory String
- PDF destination directory. Source names retain their extension plus .pdf.
- Password String
- Password used to open an encrypted Word, Excel, or PowerPoint source file.
- PowerPointOptions PowerPointToPdfOptions
- PowerPoint-specific PDF options.
- RetryFailed SwitchParameter
- Retry recorded failures; completed items remain protected.
- RtfOptions RtfToPdfOptions
- RTF-specific PDF options.
- SummaryVariable String
- Variable receiving the bounded batch summary, including when ItemResults is selected.
- TextOptions PdfPlainTextOptions
- Literal text layout and strict decoding options. Applies only to TXT sources.
- WordOptions WordToPdfOptions
- 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>]#PathParameters
- AllowLegacyImportLoss SwitchParameter
- Accept reported legacy DOC import loss. Known loss otherwise blocks conversion.
- ExcelOptions ExcelToPdfOptions
- Excel-specific PDF options.
- HtmlOptions HtmlToPdfOptions
- HTML-specific PDF rendering options.
- InputPath String
- Source .doc, .docx, .txt, .xlsx, .pptx, .html, .htm, .xhtml, .md, .markdown, or .rtf file.
- MarkdownOptions MarkdownToPdfOptions
- Markdown-specific PDF options.
- MaximumInputBytes Int64
- Maximum source bytes for DOC and TXT import.
- Open SwitchParameter
- Open the PDF after exporting it.
- PassThru SwitchParameter
- Emit the saved PDF file.
- Password String
- Password used to open an encrypted Word, Excel, or PowerPoint source file.
- Path String
- Destination PDF path.
- PdfConversionReportVariable String
- Variable name that receives the structured PDF conversion report.
- PdfWarningVariable String
- Variable name that receives structured PDF conversion warnings.
- PowerPointOptions PowerPointToPdfOptions
- PowerPoint-specific PDF options.
- RtfOptions RtfToPdfOptions
- RTF-specific PDF options.
- SourceConversionReportVariable String
- Variable receiving source-stage reports separately from PDF rendering diagnostics.
- TextOptions PdfPlainTextOptions
- Literal text layout and strict decoding options. Applies only to TXT sources.
- WordOptions WordToPdfOptions
- Word-specific PDF options.
Outputs
System.IO.FileInfo, OfficeIMO.Workflows.OfficeConversionBatchResult, OfficeIMO.Workflows.OfficeConversionBatchItemResult