EpubDocument

A parsed EPUB, reflowed onto fixed-size pages and rendered through the shared KiteCanvas the PDF engine uses. The second document handler on :kitepdf-core.

Pipeline: ZipReader unzips the OCF container; HtmlParser builds a DOM per spine document; the CSS cascade (StyleResolver, via BoxBuilder) turns each into a LayoutBox tree; BoxLayout resolves the box model (margins, borders, padding, width, inline line breaking with justification) into document-space geometry; Paginator slices it into pages; and EpubPage paints backgrounds, borders, text and images. See EPUB_ROAD_TO_PERFECTION.md.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

EPUB-specific metadata (title, authors, cover path, reading direction).

Link copied to clipboard
Link copied to clipboard

True for a pre-paginated (fixed-layout) book: one page per spine, no reflow.

Link copied to clipboard
Link copied to clipboard
open override val metadata: KiteMetadata

Format-neutral title/authors/language for KiteDocument viewers.

Link copied to clipboard
open override val outline: List<KiteOutlineItem>

Format-neutral outline for KiteDocument viewers: tableOfContents with each href resolved to a zero-based page index through the anchor/pagination map (null for grouping labels and unknown targets).

Link copied to clipboard
open override val pageCount: Int
Link copied to clipboard
Link copied to clipboard
open override val pages: List<EpubPage>

The reflowed pages, ready to render.

Link copied to clipboard
Link copied to clipboard

Page size, font size and margin. Change at runtime via withSettings.

Link copied to clipboard

Navigation tree from EPUB 3 nav.xhtml or EPUB 2 toc.ncx (empty if none).

Functions

Link copied to clipboard
fun pageOf(href: String): Int?

Zero-based page of an internal href: path.xhtml or path.xhtml#id, zip-root-relative, exactly as EpubPage.links and TocEntry carry them. Null for unknown targets and external URLs; an unknown fragment falls back to its document's first page. This is the navigation half of a link tap: viewers scroll to the returned page.

Link copied to clipboard
fun search(needle: String, ignoreCase: Boolean = true): Sequence<KiteSearchHit>

Find needle across the book, lazily page by page (a UI can show incremental results). Same matching rules as KiteStructuredText.search: case-insensitive by default, line breaks read as one space, a hyphenated line break joins directly, matches never cross blocks.

Link copied to clipboard

Shorthand for withSettings changing only the body font size (points).

Link copied to clipboard

Shorthand for withSettings changing only the page margin (points).

Link copied to clipboard
fun withPageSize(pageWidth: Double, pageHeight: Double): EpubDocument

Shorthand for withSettings changing the page size, e.g. on resize / rotation.

Link copied to clipboard

A copy of this book re-laid-out with new settings, reusing the parse (no re-unzip / re-parse of HTML, CSS or fonts). Use for reader controls that change font size, margins or page size at runtime, much cheaper than open.