OfficeIMO.Epub 3.0.3

Prefix Reserved
dotnet add package OfficeIMO.Epub --version 3.0.3
                    
NuGet\Install-Package OfficeIMO.Epub -Version 3.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfficeIMO.Epub" Version="3.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfficeIMO.Epub" Version="3.0.3" />
                    
Directory.Packages.props
<PackageReference Include="OfficeIMO.Epub" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OfficeIMO.Epub --version 3.0.3
                    
#r "nuget: OfficeIMO.Epub, 3.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OfficeIMO.Epub@3.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OfficeIMO.Epub&version=3.0.3
                    
Install as a Cake Addin
#tool nuget:?package=OfficeIMO.Epub&version=3.0.3
                    
Install as a Cake Tool

OfficeIMO.Epub - EPUB extraction primitives

nuget version nuget downloads

OfficeIMO.Epub provides reusable EPUB extraction primitives for modular OfficeIMO ingestion pipelines.

Install

dotnet add package OfficeIMO.Epub

Quick start

using OfficeIMO.Epub;

EpubDocument book = EpubDocument.Load("book.epub", new EpubReadOptions {
    PreferSpineOrder = true,
    IncludeRawHtml = false,
    MaxChapters = 100
});

Console.WriteLine(book.Title);

foreach (EpubChapter chapter in book.Chapters) {
    Console.WriteLine($"{chapter.Order}. {chapter.Title ?? chapter.Path}");
    Console.WriteLine(chapter.Text);
}

foreach (string warning in book.Warnings) {
    Console.WriteLine(warning);
}

Inspect bounded manifest resources

EpubDocument book = EpubDocument.Load("book.epub", new EpubReadOptions {
    IncludeResourceData = true,
    MaxResources = 500,
    MaxResourceBytes = 4L * 1024L * 1024L,
    MaxTotalResourceBytes = 32L * 1024L * 1024L
});

foreach (EpubResource resource in book.Resources) {
    Console.WriteLine($"{resource.Path} ({resource.MediaType}, {resource.LengthBytes} bytes)");
}

Manifest metadata is returned even when payload loading is disabled. Payload inclusion is opt-in and bounded per resource, in total, and by resource count; skipped payloads produce warnings.

Resolve chapter-relative references

EpubReference reference = EpubReference.Resolve(
    "EPUB/text/chapter.xhtml",
    "../images/cover%20art.png?size=large#front");

if (reference.Kind == EpubReferenceKind.Container) {
    Console.WriteLine(reference.ContainerPath);     // decoded ZIP lookup path
    Console.WriteLine(reference.ContainerUrlPath);  // URL-encoded link path
    Console.WriteLine(reference.ResolvedValue);     // encoded path plus query and fragment
}

Use the three-argument overload with chapter.BaseHref when resolving URLs found in chapter markup. Results distinguish container, external, embedded data, and invalid references without performing network or file-system access. ContainerPath remains case-sensitive and decoded for ZIP lookup, while ContainerUrlPath, Target, and ResolvedValue preserve a safe URL serialization. Root-relative references are resolved safely but marked non-conforming; file: URLs, ambiguous encoded separators, and paths that escape the container are rejected.

What it does

  • Opens EPUB files as ZIP containers.
  • Parses META-INF/container.xml and OPF package metadata.
  • Follows OPF manifest and spine ordering.
  • Reads hierarchical EPUB 3 navigation and EPUB 2 NCX labels when available.
  • Extracts chapter text from XHTML/XML ASTs.
  • Returns deterministic OPF manifest resources with optional bounded payloads.
  • Resolves package, navigation, and content references through a shared typed URL contract.
  • Emits structured diagnostics and warning messages for malformed, unsafe, encrypted, fixed-layout, or unreadable content.

Examples

Read metadata and spine-ordered chapters

using OfficeIMO.Epub;

EpubDocument book = EpubDocument.Load("handbook.epub", new EpubReadOptions {
    PreferSpineOrder = true,
    IncludeNonLinearSpineItems = false,
    MaxChapters = 50
});

Console.WriteLine(book.Title);
Console.WriteLine(book.Creator);
Console.WriteLine(book.Language);

foreach (var chapter in book.Chapters) {
    Console.WriteLine($"{chapter.Order}. {chapter.Title ?? chapter.Path}");
}

Keep raw chapter HTML when building a converter

using OfficeIMO.Epub;

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

foreach (var chapter in book.Chapters) {
    File.WriteAllText(
        $"chapter-{chapter.Order:000}.txt",
        chapter.Text);

    if (chapter.Html != null) {
        File.WriteAllText($"chapter-{chapter.Order:000}.xhtml", chapter.Html);
    }
}

Read from a stream and report warnings

using OfficeIMO.Epub;

await using var stream = File.OpenRead("upload.epub");
EpubDocument book = EpubDocument.Load(stream, new EpubReadOptions {
    FallbackToHtmlScan = true,
    DeterministicOrder = true
});

foreach (string warning in book.Warnings) {
    Console.WriteLine(warning);
}

Boundaries

  • This package owns reusable EPUB parsing primitives.
  • Reader integration belongs in OfficeIMO.Reader.Epub.
  • The parser is read-only and does not attempt CSS layout, scripting, DRM, or package mutation.

Targets and license

Dependency footprint

  • External: None; no third-party EPUB engine.
  • OfficeIMO: OfficeIMO.Drawing. Container, OPF, spine, navigation, chapter, and resource parsing are first-party.

See the complete OfficeIMO package map for related formats and conversion paths.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OfficeIMO.Epub:

Package Downloads
OfficeIMO.Reader.Epub

EPUB adapter for OfficeIMO.Reader modular ingestion.

OfficeIMO.Epub.Image

Thin EPUB-to-image adapter over OfficeIMO.Html and OfficeIMO.Drawing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.3 205 7/27/2026
3.0.2 220 7/26/2026
3.0.1 368 7/26/2026
3.0.0 529 7/20/2026
2.0.1 295 7/14/2026
2.0.0 136 7/14/2026
0.0.33 253 7/9/2026
0.0.32 317 7/8/2026
0.0.31 463 7/5/2026
0.0.30 235 7/4/2026
0.0.29 265 6/27/2026
0.0.28 150 6/27/2026
0.0.27 407 6/24/2026
0.0.26 200 6/23/2026
0.0.25 311 6/21/2026
0.0.24 155 6/16/2026
0.0.23 349 6/16/2026
0.0.22 195 6/15/2026
0.0.21 165 6/13/2026
0.0.20 147 6/12/2026
Loading failed