PdfSaveAction

fun interface PdfSaveAction

Action that persists a PDF to a user-visible location on the device.

Returned by rememberPdfSaveAction and typically wired to a "Save" affordance in the host app's chrome (top app bar, action sheet, …). Each invocation writes bytes to a platform-appropriate destination:

  • AndroidDownloads/<fileName> via MediaStore.Downloads (API 29+) or the legacy Environment.DIRECTORY_DOWNLOADS on older devices, then surfaces a Toast confirmation. Visible in the system Files app under "Downloads" alongside any browser download.

  • iOS<NSDocumentDirectory>/<fileName> (the app's documents container, surfaced in the Files app under "On My iPhone / "). iOS doesn't expose a true "Downloads" folder; this matches the behaviour of system apps that offer "Save".

Parameters

bytes

encoded PDF payload to persist.

fileName

user-visible filename (must include the .pdf extension). The implementation overwrites any existing file with the same name in the destination — callers that need uniqueness should add a timestamp / counter before passing it in.

Functions

Link copied to clipboard
abstract operator fun invoke(bytes: ByteArray, fileName: String)