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
The format bytes are in, or null when they are none of them.
Reads bytes as whichever format they are.
Drains stream and opens what comes out. The stream is closed either way.
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.
Opens data you already hold, e.g. from a network call or the pasteboard.
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.
Drains stream and opens what comes out. The stream is closed either way.
open over Base64 text.
openBase64, but null instead of an exception.
Reads the file at path and opens it as whichever format it is.
Reads the file at path and opens it as whichever format it is.
Reads the file at path and opens it as whichever format it is.
Reads the file at path and opens it as whichever format it is.
open, but null instead of an exception on anything unreadable.