# Convert Word to PDF, HTML, and Markdown

Convert DOCX to PDF, HTML, Markdown, ODT and RTF, and create Word documents from HTML or Markdown, with OfficeIMO.Word converters and PSWriteOffice.

**Packages**

- [OfficeIMO.Word](https://www.nuget.org/packages/OfficeIMO.Word) `dotnet add package OfficeIMO.Word`
- [OfficeIMO.Word.Pdf](https://www.nuget.org/packages/OfficeIMO.Word.Pdf) `dotnet add package OfficeIMO.Word.Pdf`
- [OfficeIMO.Word.Html](https://www.nuget.org/packages/OfficeIMO.Word.Html) `dotnet add package OfficeIMO.Word.Html`
- [OfficeIMO.Word.Markdown](https://www.nuget.org/packages/OfficeIMO.Word.Markdown) `dotnet add package OfficeIMO.Word.Markdown`
- [OfficeIMO.Word.OpenDocument](https://www.nuget.org/packages/OfficeIMO.Word.OpenDocument) `dotnet add package OfficeIMO.Word.OpenDocument`
- [OfficeIMO.Word.Rtf](https://www.nuget.org/packages/OfficeIMO.Word.Rtf) `dotnet add package OfficeIMO.Word.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, net10.0, net472

**APIs**

- [`WordDocument`](/api/word/officeimo-word-worddocument/)
- [`HtmlConversionDocument`](/api/html/officeimo-html-htmlconversiondocument/)
- [`OfficeConversionReport`](/api/core/officeimo-officeconversionreport/)
- [`MarkdownDocument`](/api/markdown/officeimo-markdown-markdowndocument/)
- [`OfficeDiagnostic`](/api/core/officeimo-officediagnostic/)
- [`WordParagraphStyles`](/api/word/officeimo-word-wordparagraphstyles/)
- [`WordPdfExportOptions`](/api/word-pdf/officeimo-word-pdf-wordpdfexportoptions/)

**Cmdlets**

- [`Convert-OfficeDocument`](/api/powershell/convert-officedocument/)
- [`New-OfficeWordPdfOptions`](/api/powershell/new-officewordpdfoptions/)
- [`New-OfficeWordMarkdownOptions`](/api/powershell/new-officewordmarkdownoptions/)

**Commands**

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

**Limits**

PDF output is laid out by OfficeIMO's own renderer; complex layouts, floating objects, and fonts missing on the machine can paginate differently from Word, and the conversion report lists what was approximated. [OfficeIMO.Word support matrix](/compatibility/#package-word), [OfficeIMO.Word.Pdf support matrix](/compatibility/#package-word-pdf), [OfficeIMO.Word.Html support matrix](/compatibility/#package-word-html), [OfficeIMO.Word.Markdown support matrix](/compatibility/#package-word-markdown), [OfficeIMO.Word.OpenDocument support matrix](/compatibility/#package-word-opendocument), [OfficeIMO.Word.Rtf support matrix](/compatibility/#package-word-rtf)

**Verified**

Examples compiled against the source on 2026-11-14

**Data**

- [OfficeIMO.Word API index](/api/word/index.json)
- [OfficeIMO.Word.Pdf API index](/api/word-pdf/index.json)
- [OfficeIMO.Word.Html API index](/api/word-html/index.json)
- [OfficeIMO.Word.Markdown API index](/api/word-markdown/index.json)
- [OfficeIMO.Word.OpenDocument API index](/api/word-open-document/index.json)
- [OfficeIMO.Word.Rtf API index](/api/word-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 format has its own package so an application only takes the converter it ships. Install `OfficeIMO.Word` plus the converter, then call the `SaveAs...` extension method it adds to `WordDocument`. Every conversion returns an `OfficeConversionReport`; its `Diagnostics` list content that was approximated or dropped, so check them, or set `FailOnLoss` on the options to throw instead.

| Destination | Package | Method |
|---|---|---|
| PDF | `OfficeIMO.Word.Pdf` | `SaveAsPdf`, `ToPdf` |
| HTML | `OfficeIMO.Word.Html` | `SaveAsHtml`, `ToHtml` |
| Markdown | `OfficeIMO.Word.Markdown` | `SaveAsMarkdown`, `ToMarkdown` |
| OpenDocument (ODT) | `OfficeIMO.Word.OpenDocument` | `SaveAsOpenDocument` |
| RTF | `OfficeIMO.Word.Rtf` | `SaveAsRtf` |

## Convert a Word document to PDF

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Word;
using OfficeIMO.Word.Pdf;

using WordDocument document = WordDocument.Load("contract.docx");
OfficeConversionReport report = document.SaveAsPdf("contract.pdf");

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

### PowerShell

```powershell
Convert-OfficeDocument -Path .\contract.docx -OutputPath .\contract.pdf
Get-ChildItem .\contracts -Filter *.docx | Convert-OfficeDocument -To Pdf -OutputDirectory .\pdf -SummaryVariable summary
$summary
```

### CLI

```sh
officeimo convert contract.docx contract.pdf
officeimo convert contract.docx contract.pdf --require-no-loss
```

## Stop when the PDF would lose content

### C#

```csharp
using OfficeIMO.Word;
using OfficeIMO.Word.Pdf;

using WordDocument document = WordDocument.Load("contract.docx");
document.SaveAsPdf("contract.pdf", new WordPdfExportOptions {
    FailOnLoss = true,
    FontFamily = "Arial"
});
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\contract.docx -OutputPath .\contract.pdf -FailOnLoss
```

## Convert a Word document to HTML

### C#

```csharp
using OfficeIMO.Word;
using OfficeIMO.Word.Html;

using WordDocument document = WordDocument.Load("newsletter.docx");
document.SaveAsHtml("newsletter.html");

string fragment = document.ToHtml();
Console.WriteLine(fragment.Length);
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\newsletter.docx -To Html -OutputPath .\newsletter.html
```

## Create a Word document from HTML

`HtmlConversionDocument` parses the HTML once; `SaveAsWord` writes the DOCX. To add HTML into a document you are already building, use `document.AddHtml(html)`.

### C#

```csharp
using OfficeIMO.Html;
using OfficeIMO.Word;
using OfficeIMO.Word.Html;

HtmlConversionDocument html = HtmlConversionDocument.Parse(
    "<h1>Release notes</h1><p>Version <strong>2.0</strong> is available.</p><ul><li>Faster load</li></ul>");
html.SaveAsWord("release-notes.docx");

using WordDocument document = WordDocument.Create("mixed.docx");
document.AddParagraph("Generated summary").Style = WordParagraphStyles.Heading1;
document.AddHtml("<p>Imported <em>HTML</em> content.</p>");
document.Save();
```

### PowerShell

```powershell
'<h1>Review</h1>', '<p>Approved.</p>' | Convert-OfficeDocument -Text { $_ } -From Html -To Word -OutputPath .\review.docx
```

### CLI

```sh
officeimo convert release-notes.html release-notes.docx
```

## Convert a Word document to Markdown

Headings, lists, tables, links, emphasis, and images map to Markdown. Features with no Markdown equivalent, such as page layout or text boxes, are reported in the diagnostics.

### C#

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

using WordDocument document = WordDocument.Load("handbook.docx");
OfficeConversionReport report = document.SaveAsMarkdown("handbook.md");
Console.WriteLine($"{report.Diagnostics.Count} diagnostics");

MarkdownDocument markdown = document.ToMarkdown();
Console.WriteLine(markdown.ToMarkdown());
```

### PowerShell

```powershell
$options = New-OfficeWordMarkdownOptions -ImageExportMode File -ImageDirectory .\handbook-images
Convert-OfficeDocument -Path .\handbook.docx -To Markdown -OutputPath .\handbook.md -Options $options
```

### CLI

```sh
officeimo convert handbook.docx handbook.md --assets handbook-images
```

## Create a Word document from Markdown

### C#

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

MarkdownDocument markdown = MarkdownDocument.Parse("""
    # Release notes

    Version **2.0** adds:

    - Faster load
    - Dark theme
    """);
markdown.SaveAsWord("release-notes.docx");
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\release-notes.md -To Word -OutputPath .\release-notes.docx
```

### CLI

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

## Convert to OpenDocument or RTF

### C#

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

using WordDocument document = WordDocument.Load("letter.docx");
document.SaveAsOpenDocument("letter.odt");
document.SaveAsRtf("letter.rtf");
```

### PowerShell

```powershell
Convert-OfficeDocument -Path .\letter.docx -OutputPath .\letter.odt
```

### CLI

```sh
officeimo convert letter.docx letter.odt
officeimo convert letter.rtf letter.docx
```

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

<!-- PowerForge markdown artifact sha256:569C6F46FA32D3895F3C207A045930379E00C611D7DE8AA46D073078851188F7 -->
