Skip to main content
KPDF deliberately does not own the share UI. Instead, exportPdf() returns the current PDF as a Result<ByteArray>. You take those bytes and pass them to your own Android Intent or iOS UIActivityViewController. This keeps platform share behaviour fully under your control.

Coroutine-based share example

exportPdf() is a suspending function, so launch it from a CoroutineScope. Use fold to handle success and failure in one expression:

Using onSuccess / onFailure separately

If you prefer to handle each branch independently, use onSuccess and onFailure:

Full integration example

The snippet below shows the share flow wired into a KPdfViewerToolbar, matching the full-screen example from the Display a PDF guide:
KPDF intentionally does not show a share sheet or system dialog. After exportPdf() resolves, your app is responsible for passing the ByteArray to the appropriate platform API — Intent.ACTION_SEND on Android or UIActivityViewController on iOS. This gives you full control over the share target, the MIME type, and any additional metadata.