Skip to content

Repository files navigation

EpubCore

.NET 6 / .NET Standard 2.0 library and tools for reading, writing and manipulating EPUB files.

Supported EPUB versions: 2.0, 3.0, 3.1

Installation

Install-Package EpubCore

Supported Frameworks

.NET6.0, NETSTANDARD2.0

Usage

Reading an EPUB

// Read an epub fileEpubBookbook=EpubReader.Read("my.epub");// Read metadatastringtitle=book.Title;string[]authors=book.Authors;Imagecover=book.CoverImage;// Get table of contentsICollection<EpubChapter>chapters=book.TableOfContents;// Get contained filesICollection<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 textstringtext=book.ToPlainText();// Access internal EPUB format specific data structures.EpubFormatformat=book.Format;OcfDocumentocf=format.Ocf;OpfDocumentopf=format.Opf;NcxDocumentncx=format.Ncx;NavDocumentnav=format.Nav;// Create an EPUBEpubWriter.Write(book,"new.epub");

Writing an EPUB

EpubWriterwriter=newEpubWriter();writer.AddAuthor("Foo Bar");writer.SetCover(imgData,ImageFormat.Png);writer.Write("new.epub");

Epub Book Builder

Use the fluent EpubBookBuilder to create your Epub. Much cleaner syntax and easier to understand.

varpathToSaveEPub="~/myepub.epub";varuniqueIdentifier=Guid.NewGuid().ToString();vartitle="The Title of my EBook";varauthor="Domingo Ladron";varbuilder=EpubBookBuilder.Create();builder.WithTitle(title).WithUniqueIdentifier(UniqueIdentifier).AddAuthor(author).AddChapter("Chapter 1","<html><body><h1>It was a dark and stormy night.</h1></body></html>").Build(pathToSaveEPub);

EpubCore CLI

As of 1.6.0, I've released a simple but effective epub CLI. This allows you to manipulate Epub files from the command line without needing to do any coding.

For complete details on installing and using the epub CLI, you can get details here

epub cli documentation

Releases

Packages

Used by

Contributors

Languages