KitePage

interface KitePage(source)

A renderable page from any document handler: the format-neutral fz_page equivalent. Both io.github.yuroyami.kitepdf.PdfPage and io.github.yuroyami.kitepdf.epub.EpubPage implement it, so one viewer / rasterizer path serves every format.

All coordinates are in points (1pt = 1/72in). displayToDeviceBase hides the per-format origin convention (PDF is y-up from bottom-left with page rotation; EPUB is y-down from top-left) behind a single mapping onto a top-left-origin, y-down device box [0, displayWidth] x [0, displayHeight].

Properties

Link copied to clipboard
abstract val displayHeight: Double

On-screen page height in points, after any page rotation.

Link copied to clipboard
abstract val displayWidth: Double

On-screen page width in points, after any page rotation.

Link copied to clipboard

True when the page draws text in a host font, because the text has no outlines of its own, and false when it draws none. Null when the page does not know before it draws. A rasterizer that draws host-font text on one thread only goes there at once for a page that says true, instead of drawing the page twice (#131).

Link copied to clipboard

The links of this page, each with its area and where it leads (#433). XPS and SVG pages give theirs here. A PDF page gives its links with their actions as PdfPage.annotations, and an EPUB page as EpubPage.links, so this list is empty for both.

Link copied to clipboard

False when the content of this page is not in memory, so that drawing the page or reading its text would lay its chapter out on the calling thread first. A document that drops laid-out chapters to stay within a memory budget answers false for a page of a dropped chapter. Reading it lays nothing out. True by default.

Functions

Link copied to clipboard

Maps unscaled display space onto a top-left-origin, y-down device box [0, displayWidth] x [0, displayHeight]. Compose output scaling on top:

Link copied to clipboard
open fun loadContent()

Brings the content of this page back into memory: lays its chapter out again when a memory budget dropped it. It blocks while it does that, so call it off the main thread. Does nothing by default.

Link copied to clipboard

This page's content in the order a reader that speaks would say it, each item with the role its source gave it: the elements of an EPUB page, the structure of a tagged PDF page. Empty when the page has no text or its format gives no order (#208).

Link copied to clipboard
abstract fun renderTo(canvas: KiteCanvas, deviceCtm: KiteMatrix = KiteMatrix.IDENTITY)

Paints the page into canvas under deviceCtm.

open fun renderTo(canvas: KiteCanvas, deviceCtm: KiteMatrix, cancellation: KiteCancellation)

renderTo that stops early once cancellation reads true: the page returns with the canvas closed and what it painted so far. A viewer passes it so a page the reader scrolled past stops rendering. A format that renders its pages quickly ignores it.

Link copied to clipboard

Structured text for extraction / search / selection, in display space (see KiteStructuredText for the coordinate convention), or null when the handler does not expose it. Both handlers implement this: EPUB pages natively, PDF pages by adapting their structured text.