Package-level declarations
Types
Android implementation of the imperative launcher. Each open(...) builds an Intent targeting KmpPdfViewerHostActivity, stuffs the payload into either a primitive extra (URI / small byte arrays) or a KmpPdfLauncherRegistry token, serialises the KmpPdfLaunchOptions bundle into Intent extras alongside it, and starts the activity using the application context the library captured at startup via ViewerContextInitializer.
Imperative counterpart of KmpPdfViewer.
iOS implementation of the imperative launcher.
JVM / Desktop implementation of the imperative launcher.
Controls how many rasterised page bitmaps the viewer keeps in memory while scrolling, and how aggressively it prefetches pages around the viewport.
How PdfViewer / KmpPdfViewer arranges pages in the scrollable list.
Action that hands a PDF off to the host platform's native print pipeline.
Action that persists a PDF to a user-visible location on the device.
Action that hands a PDF off to the host platform's native share sheet.
How a PdfViewerTopBar title behaves when it is too long to fit the space the bar can give it without pushing the action icons out of the way.
Action that opens an HTTP/HTTPS URL in the platform's default browser. Returned by rememberPdfUrlLauncher and invoked from the hyperlink overlay rendered on top of selected PDF pages — see PdfViewer's hyperlinksEnabled parameter.
One in-viewer highlight annotation, expressed in the same coordinate system as com.conamobile.pdfkmp.text.PdfTextRun and PdfSearchHighlight — PDF points, top-left origin, Y growing downward — so a highlight scales with pinch zoom exactly like a search-match rectangle does.
Why a PdfViewer / KmpPdfViewer could not open a document, surfaced to the host via the onDocumentError callback and used internally to pick the inline error message instead of crashing.
Properties
Material 3 "download" / "save" icon expressed as an inline ImageVector for the same reason as PdfShareIcon — keeps the library free of compose-material-icons-extended.
Material 3 "share" icon expressed as an inline ImageVector so the library does not need a transitive dependency on compose-material-icons-extended — that artifact alone adds tens of thousands of vectors and noticeably inflates consumer bundle sizes.
Functions
Computes the row layout for PdfPageLayout.TwoPageBook given a page count: a list of rows, each holding the zero-based page indices shown on that row.
Builds a normalised PdfViewerAnnotation from a drag in page-point space, given the two opposite corners (startX/startY → endX/endY). The corners are normalised so a drag in any direction (up-left, down-right, …) yields a box with non-negative width/height, and the result is clamped to the page bounds (pageWidth × pageHeight) so a highlight can never spill outside the page.
Returns the index of the topmost annotation in annotations whose box contains the point (xPoints, yPoints) on page pageIndex, or -1 if the tap missed every annotation on that page.
PdfDocument-flavoured overload — wraps the document in a PdfSource.Document and forwards. Recommended entry point when the PDF was authored through the PdfKmp DSL because text selection and hyperlinks light up automatically.
All-in-one PDF viewer screen — recommended composable entry.
Raw-bytes overload — for payloads that came from disk, the network, an ACTION_OPEN_DOCUMENT picker, or any other source. Text selection + hyperlink layers are inert because the bytes carry no position metadata; everything else (zoom, share, save, page indicator) works exactly the same.
String-URI overload, deprecated in favour of PdfSource.auto.
PdfDocument-flavoured overload of PdfSaveFab.
Material 3 FloatingActionButton that persists bytes to the user-visible Downloads folder via rememberPdfSaveAction. Same placement story as PdfShareFab — host it in PdfViewer's overlay slot or anywhere a FloatingActionButton fits.
Inline search field that morphs into the place of PdfViewerTopBar while the user is searching the document. Mirrors the handoff's "Topbar → search transition" behaviour: same height as the parent topbar, white background, divider underneath, focus-on-mount, with prev / next / close affordances and a live match counter.
PdfDocument-flavoured overload — defers the PdfDocument.toByteArray call to the click handler so re-renders don't allocate. Pair with PdfViewer's overlay slot for a one-line setup:
Material 3 FloatingActionButton that hands bytes off to the platform share sheet via rememberPdfShareAction.
Convenience overload for callers that already have raw PDF bytes (downloaded from the network, picked from ACTION_OPEN_DOCUMENT, etc.) and don't need to construct a PdfSource explicitly.
Convenience overload that accepts a PdfDocument directly.
Compose Multiplatform viewer for PDFs produced by :pdfkmp (or any other source that hands you raw %PDF-… bytes).
Android clipboard write via the system ClipboardManager, using the application Context surfaced by ViewerContextHolder (the same App-Startup-populated handle the share / save launchers use). Best- effort — a missing context or an unavailable clipboard service is swallowed rather than crashing a viewer mid-interaction.
Copies text to the host platform's system clipboard.
iOS clipboard write via the general UIPasteboard. Setting string replaces the pasteboard contents with text, which is what a "Copy" affordance over selected PDF text should do.
Desktop clipboard write via the AWT system Toolkit clipboard. Best- effort — a headless environment (no display, so no system clipboard) is swallowed rather than crashing the viewer.
Android default — delegates to PdfViewerTopBarMinimalMono.
Platform-aware default topbar for PdfViewer. Picks the design direction the host platform expects out of the box:
iOS default — delegates to PdfViewerTopBarClassicIos.
Desktop default — delegates to PdfViewerTopBarMinimalMono, the same brand-neutral, Material-flavoured bar Android uses. It reads naturally with a mouse and keyboard, where the iOS chevron-and-label convention would feel out of place.
Classic iOS Native topbar variant — matches Mail / Files / Notes conventions for products that target iOS exclusively (or that want to feel native on Apple platforms).
Minimal Mono topbar variant — modern, brand-neutral, with the download action visually elevated as the primary CTA.
Captures the (Activity) Context once and returns a PdfPrintAction that streams the PDF bytes through Android's PrintManager + a PrintDocumentAdapter.
Returns a remembered PdfPrintAction bound to the current platform's print machinery. On Android this snapshots the androidx.compose.ui.platform.LocalContext; on iOS it presents the shared platform.UIKit.UIPrintInteractionController; on Desktop it shows the native print dialog off the UI thread.
Returns a stateless PdfPrintAction that presents iOS's shared UIPrintInteractionController.
Desktop "Print" — drives java.awt.print.PrinterJob with PdfBox's PDFPageable, the same PdfBox stack the Desktop viewer already uses to rasterise pages on screen. PDFPageable feeds the embedded PDF to the printer at full vector fidelity (no intermediate rasterisation), so what prints matches the on-screen document exactly.
Captures the Context once and returns a PdfSaveAction that persists the bytes to the user-visible Downloads directory.
Returns a remembered PdfSaveAction bound to the current platform's filesystem APIs. Pair it with a showSaveButton = false-style disable on any built-in chrome and host the save affordance from a spot in your own UI — typically a top-app-bar androidx.compose.material3.IconButton.
Returns a stateless PdfSaveAction backed by the app's <NSDocumentDirectory> — the closest iOS equivalent of an Android Downloads folder. Files written here surface in the system Files app under "On My iPhone /
Desktop "Save" — pops the OS-native Save As dialog (java.awt.FileDialog in SAVE mode), pre-filled with the suggested file name and defaulting to the user's ~/Downloads folder. This is the desktop analogue of Android's MediaStore + Toast and iOS's document picker: the dialog itself is the visible confirmation, and the user controls exactly where the file lands.
Captures the Context once and returns a PdfShareAction that writes the bytes to cacheDir/pdfkmp-viewer-share/<filename> and launches a Intent.ACTION_SEND chooser through FileProvider.
Returns a remembered PdfShareAction bound to the current platform's share machinery. On Android this snapshots the androidx.compose.ui.platform.LocalContext; on iOS this snapshots the key window's root view controller.
Captures the key window's root view controller once and returns a PdfShareAction that writes the bytes into NSTemporaryDirectory and presents a UIActivityViewController from the topmost presented controller. The temp file is overwritten on every share so a regenerated document with the same name correctly replaces the previous payload.
Desktop "Share" — Desktop OSes have no system share sheet equivalent to Android's ACTION_SEND or iOS's UIActivityViewController, so the closest useful behaviour is to write the PDF to a temp file and hand it to the OS default handler via Desktop.open (Preview, Acrobat, Evince, …). From there the user can print, forward, or save-as. No-ops gracefully on headless or unsupported environments.
Scans every PdfTextRun for case-insensitive occurrences of query and returns a sorted list of PdfSearchHighlights in document order (page → top-to-bottom → left-to-right).