# Convert EPUB to PDF, Markdown and Images

Convert EPUB e-books to PDF or Markdown, render chapters to PNG or SVG images, and save chapter XHTML and text to files for your own converter.

**Packages**

- [OfficeIMO.Epub](https://www.nuget.org/packages/OfficeIMO.Epub) `dotnet add package OfficeIMO.Epub`
- [OfficeIMO.Epub.Image](https://www.nuget.org/packages/OfficeIMO.Epub.Image) `dotnet add package OfficeIMO.Epub.Image`
- [OfficeIMO](https://www.nuget.org/packages/OfficeIMO) `dotnet add package OfficeIMO`

**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**

- [`EpubDocument`](/api/epub/officeimo-epub-epubdocument/)
- [`HtmlRenderMode`](/api/html/officeimo-html-htmlrendermode/)
- [`EpubLoadOptions`](/api/epub/officeimo-epub-epubloadoptions/)
- [`OfficeConversionReport`](/api/core/officeimo-officeconversionreport/)
- [`EpubChapter`](/api/epub/officeimo-epub-epubchapter/)
- [`EpubImageExportOptions`](/api/epub-image/officeimo-epub-image-epubimageexportoptions/)
- [`OfficeDiagnostic`](/api/core/officeimo-officediagnostic/)
- [`OfficeImageExportFormat`](/api/core/officeimo-drawing-officeimageexportformat/)
- [`OfficePublicationPolicy`](/api/core/officeimo-officepublicationpolicy/)

**Cmdlets**

- [`Convert-OfficeDocument`](/api/powershell/convert-officedocument/)
- [`Read-OfficeDocument`](/api/powershell/read-officedocument/)

**Commands**

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

**Limits**

EPUB to PDF is a reading-order text conversion through the Reader, not a page-by-page rendering of the book's CSS; use the image export when appearance matters. [OfficeIMO.Epub support matrix](/compatibility/#package-epub), [OfficeIMO.Epub.Image support matrix](/compatibility/#package-epub-image), [OfficeIMO support matrix](/compatibility/#package-officeimo)

**Verified**

Examples compiled against the source on 2026-11-14

**Data**

- [OfficeIMO.Epub API index](/api/epub/index.json)
- [OfficeIMO.Epub.Image API index](/api/epub-image/index.json)
- [PSWriteOffice command catalog](/data/powershell/commands.json)
- [CLI command catalog](/data/cli/commands.json)
- [Capability catalog (JSON)](/data/capabilities.json)

Pick the route by what the output is for. For a printable or searchable copy, convert the EPUB to PDF or Markdown through the `OfficeIMO` converter or the CLI; both read the chapters in spine order. For a visual preview, `OfficeIMO.Epub.Image` renders chapters with their stylesheets and images through the HTML renderer. For your own pipeline, load the chapter XHTML and text directly from `EpubDocument`.

## Convert an EPUB to PDF

### C#

```csharp
using OfficeIMO;

OfficeConversionReport report = OfficeConverter.Convert("handbook.epub", "handbook.pdf",
    new OfficeConversionOptions { FileConflictPolicy = OfficePublicationPolicy.Replace });

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

### PowerShell

```powershell
Convert-OfficeDocument -Path .\handbook.epub -To Pdf -OutputPath .\handbook.pdf
```

### CLI

```sh
officeimo convert handbook.epub handbook.pdf
```

## Convert an EPUB to Markdown

The Reader writes the chapters as one Markdown document and can extract images into a folder.

### PowerShell

```powershell
Read-OfficeDocument -Path .\handbook.epub -As Markdown
```

### CLI

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

## Render chapters to images

Load the raw chapter HTML and resource bytes so the renderer can use the book's CSS and pictures. The default mode makes one continuous image per chapter; set `Mode = HtmlRenderMode.Paged` for page-sized images.

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Drawing;
using OfficeIMO.Epub;
using OfficeIMO.Epub.Image;
using OfficeIMO.Html;

EpubDocument book = EpubDocument.Load("handbook.epub", new EpubLoadOptions {
    IncludeRawHtml = true,
    IncludeResourceData = true
});

var options = new EpubImageExportOptions {
    Format = OfficeImageExportFormat.Png,
    ViewportWidth = 800
};

OfficeConversionReport report = book.SaveAsImages("handbook-pages", options);
Console.WriteLine($"{report.ItemsWritten} images written");
```

## Save chapter XHTML and text

`IncludeRawHtml` keeps each chapter's markup next to its extracted text, which is the starting point for a custom converter.

### C#

```csharp
using OfficeIMO.Epub;

EpubDocument book = EpubDocument.Load("handbook.epub", new EpubLoadOptions {
    IncludeRawHtml = true,
    MaxChapterBytes = 2L * 1024 * 1024
});

Directory.CreateDirectory("chapters");
foreach (EpubChapter chapter in book.Chapters) {
    File.WriteAllText(Path.Combine("chapters", $"chapter-{chapter.Order:000}.txt"), chapter.Text);
    if (chapter.Html != null) {
        File.WriteAllText(Path.Combine("chapters", $"chapter-{chapter.Order:000}.xhtml"), chapter.Html);
    }
}
```

## Convert a CHM help file to EPUB

### CLI

```sh
officeimo convert manual.chm manual.epub
```

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

<!-- PowerForge markdown artifact sha256:6B33303778965EB529DE01BB9D2FAA7206AB84E9CA3BF731A7BBDFC2E48BE0CB -->
