mob_print

System PDF printing for Mob apps — hand a PDF file on disk to the platform's native print dialog.

Usage

# Job name defaults to the filename without extension ("invoice"):
MobPrint.pdf("/path/to/invoice.pdf")

# Or set an explicit job title for the system print UI / spooler:
MobPrint.pdf("/path/to/invoice.pdf", title: "Invoice #1042")

:ok means the system print dialog was requested — not that the user tapped Print or that pages came out of a printer. No completion message is sent.

Options

Return values

Return value Meaning
:ok System print UI was requested. Does not mean the job finished printing.
{:error, :not_found} path does not exist, is not a regular file, or cannot be read.
{:error, :no_activity} App is not foregrounded, or no active Activity / foreground window is available.
{:error, :no_app} Android: no print spooler / handler activity could be started for the print action.
{:error, :failed} Platform refused to print the file (e.g. unreadable/invalid PDF or UI error).
{:error, :unsupported} Printing is unavailable on this platform/device (host build, no print service, etc.).

Install

# mix.exs
{:mob_print, "~> 0.1"}

# mob.exs
config :mob, :plugins, [:mob_print]
config :mob, :trusted_plugins, %{mob_print: "ed25519:<fingerprint>"}

mix mob.plugin.trust mob_print records the fingerprint, then mix mob.deploy --native.

Platform notes

Limitations

License

MIT.