API Reference

Cmdlet

ConvertTo-OfficeRtf

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

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

Remarks

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

Examples

Authored help example

Example 1: Convert Word to RTF.

PS>


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.

Example 2: Convert HTML to RTF.

PS>


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

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

Example 3: Convert PDF to RTF.

PS>


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

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

Example 4: Convert Markdown to RTF.

PS>


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

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

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

ConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -WordPath <String> [<CommonParameters>]
#
Parameter set: WordPath

Parameters

OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
WordPath String requiredposition: namedpipeline: False
Path to a .docx file to convert to RTF.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -WordDocument <WordDocument> [<CommonParameters>]
#
Parameter set: WordDocument

Parameters

OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
WordDocument WordDocument requiredposition: namedpipeline: True (ByValue)
Word document instance to convert to RTF.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf [-BasePath <String>] [-FontFamily <String>] -Html <String> [-OutputPath <String>] [-PassThru] [-StylesheetContent <String[]>] [-StylesheetPath <String[]>] [<CommonParameters>]
#
Parameter set: Html

Parameters

BasePath String optionalposition: namedpipeline: False
Base path used to resolve relative HTML resources.
FontFamily String optionalposition: namedpipeline: False
Optional font family for HTML to Word conversion before RTF serialization.
Html String requiredposition: namedpipeline: False
HTML markup to convert to RTF through the Word HTML converter.
OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
StylesheetContent String[] optionalposition: namedpipeline: False
Inline CSS stylesheets to apply during HTML conversion.
StylesheetPath String[] optionalposition: namedpipeline: False
Paths to CSS stylesheets to apply during HTML conversion.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf [-BasePath <String>] [-FontFamily <String>] -HtmlPath <String> [-OutputPath <String>] [-PassThru] [-StylesheetContent <String[]>] [-StylesheetPath <String[]>] [<CommonParameters>]
#
Parameter set: HtmlPath

Parameters

BasePath String optionalposition: namedpipeline: False
Base path used to resolve relative HTML resources.
FontFamily String optionalposition: namedpipeline: False
Optional font family for HTML to Word conversion before RTF serialization.
HtmlPath String requiredposition: namedpipeline: False
Path to an HTML file to convert to RTF.
OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
StylesheetContent String[] optionalposition: namedpipeline: False
Inline CSS stylesheets to apply during HTML conversion.
StylesheetPath String[] optionalposition: namedpipeline: False
Paths to CSS stylesheets to apply during HTML conversion.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf [-OutputPath <String>] [-PassThru] -PdfPath <String> [<CommonParameters>]
#
Parameter set: PdfPath

Parameters

OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
PdfPath String requiredposition: namedpipeline: False
Path to a PDF file to convert to semantic RTF.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf -Markdown <String> [-OutputPath <String>] [-PassThru] [-PreserveRawHtmlAsText] [<CommonParameters>]
#
Parameter set: Markdown

Parameters

Markdown String requiredposition: namedpipeline: False
Markdown text to convert to RTF.
OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
PreserveRawHtmlAsText SwitchParameter optionalposition: namedpipeline: False
Preserve raw HTML Markdown blocks as plain text in the RTF output.

Outputs

System.IO.FileInfo, System.String

ConvertTo-OfficeRtf -MarkdownPath <String> [-OutputPath <String>] [-PassThru] [-PreserveRawHtmlAsText] [<CommonParameters>]
#
Parameter set: MarkdownPath

Parameters

MarkdownPath String requiredposition: namedpipeline: False
Path to a Markdown file to convert to RTF.
OutputPath String optionalposition: namedpipeline: Falsealiases: OutPath
Optional destination RTF path. When omitted, raw RTF text is returned.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo when saving to disk.
PreserveRawHtmlAsText SwitchParameter optionalposition: namedpipeline: False
Preserve raw HTML Markdown blocks as plain text in the RTF output.

Outputs

System.IO.FileInfo, System.String