Export-OfficeDocumentPdf
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>]#DocumentExport-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>]#DirectoryExport-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>]#FilesExport-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>]#PathDescription
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.pdfExport a supported file without opening it explicitly.
Export-OfficeDocumentPdf -InputPath .\Report.docx -Path .\Report.pdf -PassThruConfigure 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 $optionsTyped 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-StateStream selected file outcomes and retain the final summary.
Get-ChildItem .\Documents -File | Export-OfficeDocumentPdf -OutputDirectory .\PDF -ItemResults -SummaryVariable summaryParameters
- -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.
- -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.
- -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.
- -MaximumConcurrency Int32
- Concurrent conversions. Default two; bounds keep the batch resource budget explicit.
- -MaximumFiles Int32
- Maximum discovered or explicitly selected source files.
- -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.
- -RetryFailed SwitchParameter
- Retry recorded failures; completed items remain protected.
- -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.
- -InputPaths Object[]
- Explicit source paths or FileInfo objects from Get-ChildItem.
- -InputPath String
- 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.