A C# library for reading and writing EPUB files.
Supported EPUB versions: 2.0, 3.0, 3.1
EpubSharp provides a simple and efficient way to interact with EPUB files in .NET. It supports reading metadata, table of contents, and internal resources (HTML, CSS, images, fonts) from EPUB 2.0 and 3.x documents.
- SDK: .NET 10.0 or higher
- Runtime: .NET 8.0, .NET 10.0, or compatible environments
Install the package via the NuGet Package Manager:
dotnet add package EpubSharp.dllOr via the Package Manager Console:
Install-Package EpubSharp.dll- Clone the repository.
- Build the project:
dotnet build
using EpubSharp;
// Read an EPUB file
EpubBook book = EpubReader.Read("my.epub");
// Read metadata
string title = book.Title;
string[] authors = book.Authors;
byte[] coverImage = book.CoverImage; // Note: Returns byte array in recent versions
// Get table of contents
ICollection<EpubChapter> chapters = book.TableOfContents;
// Get contained files
ICollection<EpubTextFile> html = book.Resources.Html;
ICollection<EpubTextFile> css = book.Resources.Css;
ICollection<EpubByteFile> images = book.Resources.Images;
ICollection<EpubByteFile> fonts = book.Resources.Fonts;
// Convert to plain text
string text = book.ToPlainText();
// Access internal EPUB format specific data structures
EpubFormat format = book.Format;
OcfDocument ocf = format.Ocf;
OpfDocument opf = format.Opf;
NcxDocument ncx = format.Ncx;
NavDocument nav = format.Nav;Warning
Editing capabilities are currently very limited and might not work at all. Use it at your own risk.
using EpubSharp;
EpubWriter writer = new EpubWriter();
writer.AddAuthor("Foo Bar");
writer.SetCover(imgData, ImageFormat.Png);
writer.Write("new.epub");The project uses the standard .NET CLI:
- Build:
dotnet build - Test:
dotnet test - Pack:
dotnet pack(generates NuGet package inbin/Debugorbin/Release)
EpubSharp/: Core library containing EPUB parsing and writing logic.Format/: Readers and writers for OPF, NCX, NAV, and OCF documents.Extensions/: Helper methods for zip archives, streams, and XML.
EpubSharp.Tests/: xUnit test suite with sample EPUB files.
No specific environment variables are required for this library.
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0). See the LICENSE file for details.
- Complete full write support for EPUB 3.x.
- Improve documentation for internal data structures.
- Add more comprehensive integration tests with various EPUB samples.