rememberPdfPrintAction
Captures the (Activity) Context once and returns a PdfPrintAction that streams the PDF bytes through Android's PrintManager + a PrintDocumentAdapter.
Unlike the share / save actions, printing deliberately holds the Activity context rather than applicationContext: PrintManager attaches its system print UI to the hosting activity's task, and the generic print dialog refuses to surface from a bare application context. Inside a KmpPdfViewer composition the LocalContext is exactly that activity.
The adapter is fully in-memory: onLayout reports a single document of PrintDocumentInfo.CONTENT_TYPE_DOCUMENT with an unknown page count (the framework / printer driver re-paginates the PDF itself), and onWrite copies the byte payload straight into the destination ParcelFileDescriptor. No temp file is touched.
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.
Useful when the host app wants its own print affordance — typically a toolbar / app-bar icon — instead of the built-in topbar button exposed by KmpPdfViewer (showPrint = true).
Returns a stateless PdfPrintAction that presents iOS's shared UIPrintInteractionController.
The PDF bytes are wrapped in an NSData and handed to the controller as its printingItem; UIPrintInteractionController knows how to paginate a PDF payload natively, so no per-page rendering is needed. A UIPrintInfo of UIPrintInfoOutputType.UIPrintInfoOutputGeneral configures it for an ordinary document print.
The print sheet is presented animated, mirroring how the share sheet is surfaced (rememberPdfShareAction). On iPad UIKit presents the print panel as a popover anchored to the screen automatically when presented animated, so — unlike the share sheet — no explicit sourceView anchoring is required here.
NOTE: this file targets the Apple toolchain and cannot be compiled on a non-macOS host; it needs verification on macOS / a simulator.
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.
The native print dialog (PrinterJob.printDialog) and the potentially-slow spool both run off the Compose / AWT UI thread on a daemon thread so the viewer never stutters while a job is queued. Failures (no printer installed, user cancel, headless environment) are swallowed — a print tap must never crash the host app.