ePub

Creates a new Book

ePub(url: (string | ArrayBuffer), options: object): Book
Parameters
url ((string | ArrayBuffer)) URL, Path or ArrayBuffer
options (object) to pass to the book
Returns
Book: a new Book object
Example
ePub("/path/to/book.epub", {})
Static Members
register

Book

Creates a new Book

new Book(url: string, options: object): Book
Parameters
url (string)
options (object)
Name Description
options.requestMethod method a request function to use instead of the default
options.requestCredentials [boolean] (default undefined) send the xhr request withCredentials
options.requestHeaders [object] (default undefined) send the xhr request headers
options.encoding [string] (default binary) optional to pass 'binary' or base64' for archived Epubs
options.replacements [string] (default base64) use base64, blobs, or none for replacing assets in archived Epubs
Returns
Book:
Example
new Book("/path/to/book.epub", {})
Instance Members
opened
spine
locations
navigation
pageList
open(input, [what])
load(path)
resolve(path, absolute)
section(target)
renderTo(element, options)
setRequestCredentials(credentials)
setRequestHeaders(headers)
coverUrl()
range(cfiRange)

Locations

Find Locations for a Book

new Locations(spine: Spine, request: request)
Parameters
spine (Spine)
request (request)
Instance Members
generate(chars)

Container

Handles Parsing and Accessing an Epub Container

new Container(containerDocument: [document])
Parameters
containerDocument ([document]) xml document
Instance Members
parse(containerDocument)

Packaging

Open Packaging Format Parser

new Packaging(packageDocument: document)
Parameters
packageDocument (document) OPF XML
Instance Members
parse(packageDocument)
parseSpine(spineXml, manifest)
findCoverPath(packageXml)

Navigation Parser

new Navigation(xml: document)
Parameters
xml (document) navigation html / xhtml / ncx
Instance Members

Resources

Handle Package Resources

new Resources(manifest: Manifest, options: [object])
Parameters
manifest (Manifest)
options ([object])
Name Description
options.archive [Archive]
options.resolver [method]
Instance Members
replacements(archive, resolver)
relativeTo(absolute, resolver)
get(path)

Archive

Handles Unzipping a requesting files from an Epub Archive

new Archive()
Instance Members
open(input, isBase64)
openUrl(zipUrl, isBase64)
request(url, type)
getBlob(url, mimeType)
getText(url, encoding)
getBase64(url, mimeType)
createUrl(url, options)
revokeUrl(url)

EpubCFI

EPUB CFI spec: http://www.idpf.org/epub/linking/cfi/epub-cfi.html

Implements:

  • Character Offset: epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3)
  • Simple Ranges : epubcfi(/6/4[chap01ref]!/4[body01]/10[para05],/2/1:1,/3:4)

Does Not Implement:

  • Temporal Offset (~)
  • Spatial Offset (@)
  • Temporal-Spatial Offset (~ + @)
  • Text Location Assertion ([)
new EpubCFI(cfiFrom: any, base: any, ignoreClass: any)
Parameters
cfiFrom (any)
base (any)
ignoreClass (any)

Url

creates a uri object

new Url(urlString: string, baseString: [string]): object
Parameters
urlString (string) a url string (relative or absolute)
baseString ([string]) optional base for the url, default to window.location.href
Returns
object: url

content

content
Properties
hooks.content (method)

Rendition

[Rendition description]

new Rendition(book: Book, options: object)
Parameters
book (Book)
options (object)
Name Description
options.width int
options.height int
options.ignoreClass string
options.manager string
options.view string
options.layout string
options.spread string
options.minSpreadWidth int overridden by spread: none (never) / both (always)
Instance Members
hooks
setManager(manager)
requireManager(manager)
requireView(view)
start()
attachTo(element)
display(target)
moveTo(offset)
next()
prev()
flow(flow)
layout(settings)
spread(spread, min)
reportLocation()
destroy()
range(cfi, ignoreClass)
adjustImages(view)

Hook

Hooks allow for injecting functions that must all complete in order before finishing They will execute in parallel but all must finish before continuing Functions may return a promise if they are asycn.

new Hook(context: any)
Parameters
context (any) scope of this
Example
this.content = new EPUBJS.Hook(this);
Instance Members
register()
trigger()

Layout

Figures out the CSS to apply for a layout

new Layout(settings: object)
Parameters
settings (object)
Name Description
settings.spread [string]
Instance Members
flow(flow)
spread(spread, min)
calculate(_width, _height, _gap)
format(contents)
count(totalWidth)