# Convert RTF to Word, PDF, Markdown and HTML

Convert RTF files to DOCX, PDF, Markdown or HTML, and convert Word, Markdown or PDF back to RTF, with a report of anything that was flattened or omitted.

**Packages**

- [OfficeIMO.Rtf](https://www.nuget.org/packages/OfficeIMO.Rtf) `dotnet add package OfficeIMO.Rtf`
- [OfficeIMO.Word.Rtf](https://www.nuget.org/packages/OfficeIMO.Word.Rtf) `dotnet add package OfficeIMO.Word.Rtf`
- [OfficeIMO.Rtf.Pdf](https://www.nuget.org/packages/OfficeIMO.Rtf.Pdf) `dotnet add package OfficeIMO.Rtf.Pdf`
- [OfficeIMO.Rtf.Markdown](https://www.nuget.org/packages/OfficeIMO.Rtf.Markdown) `dotnet add package OfficeIMO.Rtf.Markdown`
- [OfficeIMO.Html.Rtf](https://www.nuget.org/packages/OfficeIMO.Html.Rtf) `dotnet add package OfficeIMO.Html.Rtf`

**Works with**

- .NET
- [PowerShell](/docs/pswriteoffice/install/) `Install-Module PSWriteOffice`
- [CLI](/docs/cli/install/) `dotnet tool install --global OfficeIMO.Tool`

**Target frameworks**

netstandard2.0, net8.0, net10.0, net472

**APIs**

- [`RtfDocument`](/api/rtf/officeimo-rtf-rtfdocument/)
- [`WordDocument`](/api/word/officeimo-word-worddocument/)
- [`OfficeConversionReport`](/api/core/officeimo-officeconversionreport/)
- [`MarkdownDocument`](/api/markdown/officeimo-markdown-markdowndocument/)
- [`RtfHtmlExportOptions`](/api/html-rtf/officeimo-html-rtfhtmlexportoptions/)
- [`OfficeDiagnostic`](/api/core/officeimo-officediagnostic/)
- [`OfficeVisualThemeKind`](/api/core/officeimo-drawing-officevisualthemekind/)
- [`RtfMarkdownExportOptions`](/api/rtf-markdown/officeimo-rtf-markdown-rtfmarkdownexportoptions/)
- [`RtfPdfExportOptions`](/api/rtf-pdf/officeimo-rtf-pdf-rtfpdfexportoptions/)
- [`RtfWordExportOptions`](/api/word-rtf/officeimo-word-rtf-rtfwordexportoptions/)

**Cmdlets**

- [`Convert-OfficeDocument`](/api/powershell/convert-officedocument/)
- [`New-OfficeRtfPdfOptions`](/api/powershell/new-officertfpdfoptions/)

**Commands**

- [`officeimo convert`](/docs/cli/convert/)

**Limits**

Paragraph frames become ordinary text flow in Word and PDF, and Markdown output omits headers, footers and annotations; each case is reported, and FailOnLoss turns it into an error. [OfficeIMO.Rtf support matrix](/compatibility/#package-rtf), [OfficeIMO.Word.Rtf support matrix](/compatibility/#package-word-rtf), [OfficeIMO.Rtf.Pdf support matrix](/compatibility/#package-rtf-pdf), [OfficeIMO.Rtf.Markdown support matrix](/compatibility/#package-rtf-markdown), [OfficeIMO.Html.Rtf support matrix](/compatibility/#package-html-rtf)

**Verified**

Examples compiled against the source on 2026-11-14

**Data**

- [OfficeIMO.Rtf API index](/api/rtf/index.json)
- [OfficeIMO.Word.Rtf API index](/api/word-rtf/index.json)
- [OfficeIMO.Rtf.Pdf API index](/api/rtf-pdf/index.json)
- [OfficeIMO.Rtf.Markdown API index](/api/rtf-markdown/index.json)
- [OfficeIMO.Html.Rtf API index](/api/html-rtf/index.json)
- [PSWriteOffice command catalog](/data/powershell/commands.json)
- [CLI command catalog](/data/cli/commands.json)
- [Capability catalog (JSON)](/data/capabilities.json)

Each destination has its own small adapter package, and every adapter reports what it preserved, flattened, omitted or blocked. Set `FailOnLoss = true` on the options, or call `ThrowIfLoss()` on the report, when a conversion has to be exact. PDF export is a layout conversion; Word, Markdown and HTML are semantic conversions that keep the document editable.

| Destination | Package | Call |
|---|---|---|
| Word (.docx) | `OfficeIMO.Word.Rtf` | `ToWord`, `SaveAsWord` |
| PDF | `OfficeIMO.Rtf.Pdf` | `ToPdf`, `SaveAsPdf` |
| Markdown | `OfficeIMO.Rtf.Markdown` | `ToMarkdown`, `SaveAsMarkdown` |
| HTML | `OfficeIMO.Html.Rtf` | `ToHtml`, `SaveAsHtml` |

## Convert RTF to Word

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Rtf;
using OfficeIMO.Word;
using OfficeIMO.Word.Rtf;

RtfDocument rtf = RtfDocument.Create();
rtf.AddParagraph().AddText("Service agreement").SetBold();
rtf.AddParagraph("Effective from January 1.");

using WordDocument word = rtf.ToWord(new RtfWordExportOptions(), out OfficeConversionReport report);
word.Save("agreement.docx");

foreach (OfficeDiagnostic diagnostic in report.Diagnostics) {
    Console.WriteLine($"{diagnostic.Code}: {diagnostic.Message}");
}
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\agreement.rtf -To Word -OutputPath .\agreement.docx
```

### CLI

```sh
officeimo convert agreement.rtf agreement.docx
```

## Convert RTF to PDF

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Rtf;
using OfficeIMO.Rtf.Pdf;

RtfDocument rtf = RtfDocument.Create();
rtf.AddParagraph("Invoice 2026-041");
rtf.AddParagraph("Total due: 1,250.00");

OfficeConversionReport report = rtf.SaveAsPdf("invoice.pdf", new RtfPdfExportOptions());
Console.WriteLine($"Loss reported: {report.HasLoss}");
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\invoice.rtf -To Pdf -OutputPath .\invoice.pdf
```

### CLI

```sh
officeimo convert invoice.rtf invoice.pdf
```

## Convert RTF to Markdown

Footnotes and endnotes become Markdown footnotes. Supply an image exporter to write pictures next to the Markdown file.

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Rtf;
using OfficeIMO.Rtf.Markdown;

RtfDocument rtf = RtfDocument.Create();
rtf.AddParagraph().AddText("Release notes").SetBold();
rtf.AddParagraph("Fixed the export timeout.");

var options = new RtfMarkdownExportOptions {
    ImagePathFactory = (_, index) => $"media/image-{index + 1}.png",
    ImageExporter = (image, _, path) => {
        Directory.CreateDirectory(Path.GetDirectoryName(path)!);
        File.WriteAllBytes(path, image.Data);
    }
};

OfficeConversionReport report = rtf.SaveAsMarkdown("release-notes.md", options);
Console.WriteLine(File.ReadAllText("release-notes.md"));
```

### CLI

```sh
officeimo convert release-notes.rtf release-notes.md
```

## Convert RTF to HTML

The web-safe profile writes bounded semantic HTML; the print-review profile writes a complete styled page.

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Drawing;
using OfficeIMO.Html;
using OfficeIMO.Rtf;

RtfDocument rtf = RtfDocument.Create();
rtf.AddParagraph("Hello from RTF");

string fragment = rtf.ToHtml(RtfHtmlExportOptions.CreateWebSafeProfile(), out OfficeConversionReport report);
string page = rtf.ToHtml(RtfHtmlExportOptions.CreatePrintReviewProfile(OfficeVisualThemeKind.WordLike));

File.WriteAllText("hello.html", page);
Console.WriteLine(fragment);
```

## Convert Word, Markdown or PDF to RTF

The same adapters work in the other direction.

### C#

```csharp
using OfficeIMO.Markdown;
using OfficeIMO.Rtf;
using OfficeIMO.Rtf.Markdown;
using OfficeIMO.Word;
using OfficeIMO.Word.Rtf;

using (WordDocument word = WordDocument.Create("letter.docx")) {
    word.AddParagraph("Dear customer,");
    word.Save();
}

using (WordDocument word = WordDocument.Load("letter.docx")) {
    word.SaveAsRtf("letter.rtf");
}

MarkdownDocument markdown = MarkdownDocument.Parse("# Notes\n\n- First\n- Second\n");
RtfDocument fromMarkdown = markdown.ToRtf();
File.WriteAllText("notes.rtf", fromMarkdown.ToRtf());
```

PDF import (`pdf.ToRtf(...)` from `OfficeIMO.Rtf.Pdf`) recovers metadata, headings, paragraphs and list items as editable RTF. Tables, images and form fields are reported rather than reconstructed.

<!-- PowerForge markdown source sha256:0179AE66963562FAEA7394F144735D594379AC7A3F8952B8A459D0CFC4617B1B; title=True -->

<!-- PowerForge markdown artifact sha256:4F7F659B357679F2241998C3574B9BBA42A1AE4996ECDAA646AC81BEF29BC273 -->
