JFLib

plat/android_print.rs#

Source: lib/plat/android_print.rs

android_print -- printing on Android: the job as our PDF (print.rs) to the system's PrintManager
(android/GalleryPrint.java: a PrintDocumentAdapter that hands the PDF over; docs/ANDROID.md AN4)

  print(job) -> 0 the system's print dialog has the job / ERR_UNSUPPORTED / ERR_DIMS / ERR_IO /
       ERR_NOMEM.  The job laid out on its paper (job.paper, PJF_LANDSCAPE) as a one-page PDF
       (print_pdf), handed to PrintManager.print.  The system's dialog -- a printer or "Save as
       PDF", paper, copies, pages, with a preview of the PDF -- runs after print returns (the UI
       thread must not wait for it: five seconds without an answer are an ANR), so 0 says the
       dialog has the job, not that paper came out; job.copies = 1.  The job's paper and
       orientation are the dialog's first choice; another paper scales the page (the print
       spooler does that).
  doc_begin / doc_image / doc_end / doc_abort   (print.rs PrintDoc, E9) no dialog before the
       pages (the system's comes with the document, at end): page() is the job's paper, the pages
       go into one PDF (pdf_native; add_pdf takes the app's own), end hands it over.
  available() -> bool   the host has a print service and an activity (CALL_PRINT); a program
       without the Java host (android/exe_main.c, the test APK) has none: ERR_UNSUPPORTED.
  Test variant (never a dialog): jfgui_PRINT_TO=FILE writes the PDF into FILE, as on Linux
       (jfgui_PRINT_SMASK=1: alpha as /SMask instead of white).

REQUEST_PRINT (web.rs, detached): the title (u32 length + UTF-8), u32 paper (PAPER_*), u32
flags (PJF_LANDSCAPE), u32 pages, then the PDF.  GalleryPrint takes it (the request stays
pending) or refuses it at once (-3: no print service, no activity; the request is gone right
after host_request, which print reads as ERR_UNSUPPORTED); later it completes with 2 (the
system took the job), -4 (cancelled in the dialog) or a failure.
  • fn print(job: &mut PrintJob<'_>) -> i32 print one image on one page (see the file header) [plat_print]

Source: docs/API.md in the JFLib repository.