Giter Club home page Giter Club logo

quickepub's Introduction

QuickEPUB

License NuGet CI Build

QuickEPUB is an open-source .NET library for generating simple eBooks in the EPUB format.

EPUB is a very powerful and flexible format for publishing eBooks. Most open-source libraries for creating EPUBs are just as powerful and flexible, but often require you to really understand how EPUBs work in order to use them effectively.

QuickEPUB is for developers that want a quick and easy way to take HTML content and export simple EPUB files from their apps.

Install

QuickEPUB is published on NuGet Gallery: https://www.nuget.org/packages/QuickEPUB

Use this command in the NuGet Package Manager console to install QuickEPUB manually:

Install-Package QuickEPUB

Usage

Using QuickEPUB is as easy as:

  1. Create an Epub instance, specifying the title and author of the book
  2. (Optional) Specify a language and/or unique identifier (ISBN, URL, whatever)
  3. Add sections of HTML content, each of which will get an entry in the table of contents
  4. (Optional) Add any CSS/image resources that are referenced in the HTML
  5. Export the instance to a file

Sample Code

// Create an Epub instance
var doc = new Epub("Book Title", "Author Name");

// Adding sections of HTML content
doc.AddSection("Chapter 1", "<p>Lorem ipsum dolor sit amet...</p>");

// Adding sections of HTML content (that reference image files)
doc.AddSection("Chapter 2", "<p><img src=\"image.jpg\" alt=\"Image\"/></p>");

// Adding images that are referenced in any of the sections
using (var jpgStream = new FileStream("image.jpg", FileMode.Open))
{
    doc.AddResource("image.jpg", EpubResourceType.JPEG, jpgStream);
}

// Adding sections of HTML content (that use a custom CSS stylesheet)
doc.AddSection("Chapter 3", "<p class=\"body-text\">Lorem ipsum dolor sit amet...</p>", "custom.css");

// Add the CSS file referenced in the HTML content
using (var cssStream = new FileStream("custom.css", FileMode.Open))
{
    doc.AddResource("custom.css", EpubResourceType.CSS, cssStream);
}

// Export the result
using (var fs = new FileStream("sample.epub", FileMode.Create))
{
    doc.Export(fs);
}

This sample code will create an EPUB named sample.epub with three sections in its table of contents:

  1. Chapter 1
  2. Chapter 2
  3. Chapter 3

The EPUB will also contain the two specified resource files: image.jpg and custom.css.

Build

Building QuickEPUB requires:

  1. A PC with the .NET 8 SDK installed
  2. The QuickEPUB source

Then you should be able to run the following command to build QuickEPUB from within its source folder:

dotnet build ./src/QuickEPUB.sln

Test

With the above setup, you should be able to run the following command to test QuickEPUB from within its source folder:

dotnet test ./src/QuickEPUB.sln

Errata

QuickEPUB is open-source under the MIT license.

Copyright (c) 2016-2024 Jon Thysell.

quickepub's People

Contributors

dmitrybarabash avatar jonthysell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

quickepub's Issues

Support properties in itemref

Your library is very easy to use! Thanks a lot!

However. it would be great if it supports something like the following in the .opf file:

  <spine page-progression-direction="rtl">
    <itemref idref="x-01" properties="rendition:page-spread-center" />
    <itemref idref="x-02" properties="page-spread-right" />
    <itemref idref="x-03" properties="page-spread-left" />
    <itemref idref="x-04" properties="page-spread-right" />
  </spine>

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.