JFLib

plat/win_print.rs (Windows)#

Source: lib/plat/win_print.rs

win_print -- printing on Windows: PrintDlgExW (comdlg32, loaded at run time) and GDI
                                                     [src/plat/win/win_print.s; docs/modules/PRINT.md]

  print(job) -> 0 printed / ERR_CANCEL / ERR_UNSUPPORTED / ERR_IO / ERR_NOMEM / ERR_DIMS.
       The system print dialog (printer, paper, orientation, copies; the job's paper and
       PJF_LANDSCAPE preselected through a DEVMODE) returns a printer DC; the page geometry
       comes from GetDeviceCaps (PHYSICALWIDTH / -OFFSET, HORZRES, LOGPIXELS), layout()
       places the image, which goes out with StretchDIBits (HALFTONE) in bands of at most
       BAND_BYTES of 24-bit rows composited over white (row_white), clipped to the
       printable area (IntersectClipRect).
  Test variant (never a dialog, never paper):
       jfgui_PRINT_TO=FILE          output goes to FILE (DOCINFO.lpszOutput) on the printer
       jfgui_PRINT_PRINTER=NAME     (default "Microsoft Print to PDF"), opened with
                                     CreateDCW and a DEVMODE for paper / orientation
       Without a main window (headless) and without jfgui_PRINT_TO: ERR_UNSUPPORTED.
  doc_begin / doc_image / doc_end / doc_abort   (print.rs PrintDoc, E9) the same dialog (a
       page range when the job names its pages: PD_PAGENUMS -> DocSys::ranges) and DC,
       StartDocW once, then per page StartPage, the bands of layout()'s rectangle in a
       SaveDC / RestoreDC around the clip, EndPage; EndDocW at the end, AbortDoc when dropped.
The gdi32 functions are imported directly (the assembly took ten of them with
GetProcAddress only to keep its import library small); PrintDlgExW (comdlg32),
GetDefaultPrinterW (winspool.drv) and CoInitializeEx (ole32) are loaded at run time.
  • 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.