Package-level declarations

The EPUB object model: Book and everything it holds — Metadata, Resources / Resource, Spine, TableOfContents, Guide, plus the MediaTypes registry and a stylesheet DSL.

Types

Link copied to clipboard
data class Author(val firstname: String = "", val lastname: String = "", var relator: Relator = Relator.AUTHOR)

Represents one of the authors of the book

Link copied to clipboard
class Book

Representation of a Book.

Link copied to clipboard
annotation class CssDsl
Link copied to clipboard
class Date(val value: String, val event: Date.Event? = null)

A Date used by the book's metadata.

Link copied to clipboard
class EpubResourceProvider(fileSystem: FileSystem, zipPath: Path) : LazyResourceProvider

Lazily reads resources from an EPUB on disk.

Link copied to clipboard
class Guide

The guide is a selection of special pages of the book. Examples of these are the cover, list of illustrations, etc.

Link copied to clipboard

These are references to elements of the book's guide.

Link copied to clipboard
class Identifier(val scheme: String = Scheme.UUID, val value: String = Uuid.random().toString())

A Book's identifier.

Link copied to clipboard
class LazyResource(resourceProvider: LazyResourceProvider, cachedSize: Long, zipEntryName: String, href: String = zipEntryName) : Resource

A Resource that loads its bytes only on-demand from an EPUB file.

Link copied to clipboard

Loads the bytes for a resource on demand.

Link copied to clipboard
Link copied to clipboard
data class MediaType(val name: String, val defaultExtension: String, val extensions: List<String>)

MediaType is used to tell the type of content a resource is.

Link copied to clipboard
object MediaTypes

Manages mediatypes that are used by epubs

Link copied to clipboard
class Metadata

A Book's collection of Metadata. In the future it should contain all Dublin Core attributes, for now it contains a set of often-used ones.

Link copied to clipboard

A relator denotes which role a certain individual had in the creation/modification of the ebook.

Link copied to clipboard
open class Resource(var id: String?, var data: ByteArray?, var href: String?, var mediaType: MediaType?, var inputEncoding: String = Constants.CHARACTER_ENCODING)

Represents a resource that is part of the epub. A resource can be a html file, image, xml, etc.

Link copied to clipboard
abstract class ResourceReference(var resource: Resource?)

Base class holding a reference to a Resource.

Link copied to clipboard
class Resources

All the resources that make up the book. XHTML files, images and epub xml documents must be here.

Link copied to clipboard
Link copied to clipboard
class Spine(spineReferences: List<SpineReference>)

The spine sections are the sections of the book in the order in which the book should be read.

Link copied to clipboard
class SpineReference(resource: Resource, var linear: Boolean = true) : ResourceReference

A Section of a book. Represents both an item in the package document and a item in the index.

Link copied to clipboard
class Stylesheet(href: String = DEFAULT_HREF, css: String, id: String? = null) : Resource

A CSS Resource. Sugar over the raw Resource constructor with the right media type, a sensible default href, and a css accessor.

Link copied to clipboard
Link copied to clipboard

Curated, opinionated stylesheets you can drop in without thinking.

Link copied to clipboard
class TableOfContents(tocReferences: MutableList<TOCReference> = mutableListOf())

The table of contents of the book. The TableOfContents is a tree structure at the root it is a list of TOCReferences, each if which may have as children another list of TOCReferences.

Link copied to clipboard
open class TitledResourceReference(resource: Resource?, var title: String? = null, var fragmentId: String? = null) : ResourceReference
Link copied to clipboard
class TOCReference(title: String?, resource: Resource?, fragmentId: String?, var children: MutableList<TOCReference> = mutableListOf()) : TitledResourceReference

An item in the Table of Contents.

Functions

Link copied to clipboard
fun stylesheet(href: String = Stylesheet.DEFAULT_HREF, build: StylesheetBuilder.() -> Unit): Stylesheet

Builds a Stylesheet using a narrow typed DSL covering the common ebook cases (typography, spacing, page breaks). Use RuleBuilder.property or StylesheetBuilder.raw as escape hatches for anything not covered.