Cmdlet
ConvertTo-OfficeRtf
Converts Word, HTML, PDF, or Markdown input to RTF.
Syntax
ConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -WordPath <String> [<CommonParameters>]#Parameter set:
WordPathConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -WordDocument <WordDocument> [<CommonParameters>]#Parameter set:
WordDocumentConvertTo-OfficeRtf [-BasePath <String>] [-FontFamily <String>] -Html <String> [-OutputPath <String>] [-PassThru] [-StylesheetContent <String[]>] [-StylesheetPath <String[]>] [<CommonParameters>]#Parameter set:
HtmlConvertTo-OfficeRtf [-BasePath <String>] [-FontFamily <String>] -HtmlPath <String> [-OutputPath <String>] [-PassThru] [-StylesheetContent <String[]>] [-StylesheetPath <String[]>] [<CommonParameters>]#Parameter set:
HtmlPathConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -PdfPath <String> [<CommonParameters>]#Parameter set:
PdfPathConvertTo-OfficeRtf -Markdown <String> [-OutputPath <String>] [-PassThru] [-PreserveRawHtmlAsText] [<CommonParameters>]#Parameter set:
MarkdownConvertTo-OfficeRtf -MarkdownPath <String> [-OutputPath <String>] [-PassThru] [-PreserveRawHtmlAsText] [<CommonParameters>]#Parameter set:
MarkdownPathExamples
Convert Word to RTF.
New-OfficeWord -Path .\Report.docx { WordParagraph -Text 'Summary' }
ConvertTo-OfficeRtf -WordPath .\Report.docx -OutputPath .\Report.rtf -PassThruLoads the Word document and saves an RTF file using OfficeIMO.Word.Rtf.
Convert HTML to RTF.
ConvertTo-OfficeRtf -Html '<h1>Report</h1>' -OutputPath .\Report.rtfCreates a Word document from HTML and serializes it to RTF.
Convert PDF to RTF.
ConvertTo-OfficeRtf -PdfPath .\Report.pdf -OutputPath .\Report.rtfUses OfficeIMO.Rtf.Pdf's semantic PDF reader to write RTF output.
Convert Markdown to RTF.
ConvertTo-OfficeRtf -MarkdownPath .\Report.md -OutputPath .\Report.rtf -PassThruParses Markdown and writes RTF using OfficeIMO.Rtf.Markdown.
Parameters
- -OutputPath String
- Optional destination RTF path. When omitted, raw RTF text is returned.
- -PassThru SwitchParameter
- Emit a FileInfo when saving to disk.
- -WordPath String
- Path to a .docx file to convert to RTF.
- -WordDocument WordDocument
- Word document instance to convert to RTF.
- -BasePath String
- Base path used to resolve relative HTML resources.
- -FontFamily String
- Optional font family for HTML to Word conversion before RTF serialization.
- -Html String
- HTML markup to convert to RTF through the Word HTML converter.
- -StylesheetContent String[]
- Inline CSS stylesheets to apply during HTML conversion.
- -StylesheetPath String[]
- Paths to CSS stylesheets to apply during HTML conversion.
- -HtmlPath String
- Path to an HTML file to convert to RTF.
- -PdfPath String
- Path to a PDF file to convert to semantic RTF.
- -Markdown String
- Markdown text to convert to RTF.
- -PreserveRawHtmlAsText SwitchParameter
- Preserve raw HTML Markdown blocks as plain text in the RTF output.
- -MarkdownPath String
- Path to a Markdown file to convert to RTF.
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.