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

ConvertTo-OfficeRtf

Aliases: ConvertTo-Rtf
Module
PSWriteOffice
Aliases
ConvertTo-Rtf
Inputs
OfficeIMO.Word.WordDocument
Outputs
System.String System.IO.FileInfo

Converts Word, HTML, PDF, or Markdown input to RTF.

Syntax

ConvertTo-OfficeRtf
[-OutputPath <String>]
[-PassThru]
-WordPath <String>
[<CommonParameters>]
#
Parameter set: WordPath
ConvertTo-OfficeRtf
[-OutputPath <String>]
[-PassThru]
-WordDocument <WordDocument>
[<CommonParameters>]
#
Parameter set: WordDocument
ConvertTo-OfficeRtf
[-BasePath <String>]
[-FontFamily <String>]
-Html <String>
[-OutputPath <String>]
[-PassThru]
[-StylesheetContent <String[]>]
[-StylesheetPath <String[]>]
[<CommonParameters>]
#
Parameter set: Html
ConvertTo-OfficeRtf
[-BasePath <String>]
[-FontFamily <String>]
-HtmlPath <String>
[-OutputPath <String>]
[-PassThru]
[-StylesheetContent <String[]>]
[-StylesheetPath <String[]>]
[<CommonParameters>]
#
Parameter set: HtmlPath
ConvertTo-OfficeRtf
[-OutputPath <String>]
[-PassThru]
-PdfPath <String>
[<CommonParameters>]
#
Parameter set: PdfPath
ConvertTo-OfficeRtf
-Markdown <String>
[-OutputPath <String>]
[-PassThru]
[-PreserveRawHtmlAsText]
[<CommonParameters>]
#
Parameter set: Markdown
ConvertTo-OfficeRtf
-MarkdownPath <String>
[-OutputPath <String>]
[-PassThru]
[-PreserveRawHtmlAsText]
[<CommonParameters>]
#
Parameter set: MarkdownPath

Examples

Convert Word to RTF.

New-OfficeWord -Path .\Report.docx { WordParagraph -Text 'Summary' }
ConvertTo-OfficeRtf -WordPath .\Report.docx -OutputPath .\Report.rtf -PassThru

Loads the Word document and saves an RTF file using OfficeIMO.Word.Rtf.

Convert HTML to RTF.

ConvertTo-OfficeRtf -Html '<h1>Report</h1>' -OutputPath .\Report.rtf

Creates a Word document from HTML and serializes it to RTF.

Convert PDF to RTF.

ConvertTo-OfficeRtf -PdfPath .\Report.pdf -OutputPath .\Report.rtf

Uses OfficeIMO.Rtf.Pdf's semantic PDF reader to write RTF output.

Convert Markdown to RTF.

ConvertTo-OfficeRtf -MarkdownPath .\Report.md -OutputPath .\Report.rtf -PassThru

Parses Markdown and writes RTF using OfficeIMO.Rtf.Markdown.

Parameters

-OutputPath String optionalaliases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
-PassThru SwitchParameter optional
Emit a FileInfo when saving to disk.
-WordPath String requiredsets: WordPath
Path to a .docx file to convert to RTF.
-WordDocument WordDocument requiredpipeline: True (ByValue)sets: WordDocument
Word document instance to convert to RTF.
-BasePath String optionalsets: Html, HtmlPath
Base path used to resolve relative HTML resources.
-FontFamily String optionalsets: Html, HtmlPath
Optional font family for HTML to Word conversion before RTF serialization.
-Html String requiredsets: Html
HTML markup to convert to RTF through the Word HTML converter.
-StylesheetContent String[] optionalsets: Html, HtmlPath
Inline CSS stylesheets to apply during HTML conversion.
-StylesheetPath String[] optionalsets: Html, HtmlPath
Paths to CSS stylesheets to apply during HTML conversion.
-HtmlPath String requiredsets: HtmlPath
Path to an HTML file to convert to RTF.
-PdfPath String requiredsets: PdfPath
Path to a PDF file to convert to semantic RTF.
-Markdown String requiredsets: Markdown
Markdown text to convert to RTF.
-PreserveRawHtmlAsText SwitchParameter optionalsets: Markdown, MarkdownPath
Preserve raw HTML Markdown blocks as plain text in the RTF output.
-MarkdownPath String requiredsets: MarkdownPath
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.