openUrl

suspend fun KiteDoc.openUrl(url: String, client: HttpClient, password: String = "", epubSettings: EpubSettings = EpubSettings(), configure: HttpRequestBuilder.() -> Unit = {}): KiteDocument

Downloads url and opens it as whichever format it turns out to be.

The whole document is held in memory, here and everywhere else in KitePDF: the engine has no incremental reader, so a URL is a download followed by KiteDoc.open. Nothing is cached; call it once and keep the document.

val client = HttpClient()               // your engine, your config
val doc = KiteDoc.openUrl("https://example.com/book.epub", client)
KiteDocView(doc, Modifier.fillMaxSize())

The client is yours: KitePDF neither creates nor closes it, so timeouts, auth headers, retries and logging stay under your control. Add per-request headers through configure:

KiteDoc.openUrl(url, client) { header("Authorization", "Bearer $token") }

Parameters

password

for an encrypted PDF; ignored for EPUB.

epubSettings

page size, font size and margins for an EPUB; ignored for PDF.

configure

applied to the GET before it is sent.

Throws

when the server answers with a non-2xx status, or the body is neither a PDF nor an EPUB.

when a downloaded PDF is encrypted and password does not authenticate.


suspend fun KiteDoc.openUrl(url: String, client: HttpClient, maxBytes: Int, password: String = "", epubSettings: EpubSettings = EpubSettings(), configure: HttpRequestBuilder.() -> Unit = {}): KiteDocument

openUrl with an explicit maxBytes ceiling. Raise the default only when the caller has an independent trust boundary and enough process memory.