KiteDoc

object KiteDoc

Opens a document without being told which format it is.

PdfDocument.open and EpubDocument.open are still there and still the direct route when you know what you have. This is for the case where you don't: a file picker, a download, a folder scan. It reads the format out of the bytes and hands back a KiteDocument, which is all the Compose viewer and the shared search / selection / outline APIs ever need.

val doc = KiteDoc.open(bytes)          // A supported document handler
KiteDocView(doc, Modifier.fillMaxSize())

Lives in the kitepdf umbrella artifact, the only one that sees every handler. Depending on a single handler still gets you that handler's own entry points.

Functions

Link copied to clipboard

The format bytes are in, or null when they are none of them.

Link copied to clipboard
fun open(bytes: ByteArray, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Reads bytes as whichever format they are.

Link copied to clipboard
fun KiteDoc.open(file: File, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

openFile for a File you already hold.

fun KiteDoc.open(stream: InputStream, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Drains stream and opens what comes out. The stream is closed either way.

fun KiteDoc.open(context: Context, uri: Uri, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Opens a content uri, which is what the system file picker (ACTION_OPEN_DOCUMENT) and share intents actually hand you. A content:// Uri has no file path, so this reads it through Context.getContentResolver.

fun KiteDoc.open(data: NSData, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Opens data you already hold, e.g. from a network call or the pasteboard.

fun KiteDoc.open(url: NSURL, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Opens an NSURL. A file URL is read straight off disk; anything else is left to Foundation, so a file:// bookmark from UIDocumentPickerViewController works, and a remote URL blocks the calling thread. For remote documents prefer the kitepdf-net artifact, which fetches asynchronously.

fun KiteDoc.open(file: File, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

openFile for a File you already hold.

fun KiteDoc.open(stream: InputStream, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Drains stream and opens what comes out. The stream is closed either way.

Link copied to clipboard
fun openBase64(text: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

open over Base64 text.

Link copied to clipboard
fun openBase64OrNull(text: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument?

openBase64, but null instead of an exception.

Link copied to clipboard
fun KiteDoc.openFile(path: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Reads the file at path and opens it as whichever format it is.

fun KiteDoc.openFile(path: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Reads the file at path and opens it as whichever format it is.

fun KiteDoc.openFile(path: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Reads the file at path and opens it as whichever format it is.

fun KiteDoc.openFile(path: String, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument

Reads the file at path and opens it as whichever format it is.

Link copied to clipboard
fun openOrNull(bytes: ByteArray, password: String = "", epubSettings: EpubSettings = EpubSettings()): KiteDocument?

open, but null instead of an exception on anything unreadable.