GithubHelp home page GithubHelp logo

domingoladron / epubcore Goto Github PK

View Code? Open in Web Editor NEW
9.0 0.0 1.0 138.95 MB

.NET Core library for manipulating Epub files

License: Mozilla Public License 2.0

C# 99.85% CSS 0.06% HTML 0.02% PowerShell 0.08%
dotnet-core epub epub-generation epub-generator epub-reader epub3 writing writing-software writing-tool

epubcore's Introduction

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 file
EpubBook book = EpubReader.Read("my.epub");

// Read metadata
string title = book.Title;
string[] authors = book.Authors;
Image cover = book.CoverImage;

// 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;

// Create an EPUB
EpubWriter.Write(book, "new.epub");

Writing an EPUB

EpubWriter writer = new EpubWriter();

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.

var pathToSaveEPub = "~/myepub.epub";
var uniqueIdentifier = Guid.NewGuid().ToString();
var title = "The Title of my EBook";
var author = "Domingo Ladron";

var builder = 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

epubcore's People

Contributors

asido avatar d1mnewz avatar domingoladron avatar erlenddahl avatar jacedeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

thisaramalintha

epubcore's Issues

Get serialized details of EPub

Get the details of the EPub in a serialized form

  • JSON
  • YAML

At the command line so these values can be parsed and used in other CLI commands

CLI: Remove an epub resource

Need a tidy means of removing a resource via the CLI, and then extending this to cover all types of resources.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.