Enhance the Stage 2: Print Layout & Direct Native Raw Printing panel with essential print setup controls and an automatic layout scaler. Profiling workflows require precise control over media trays, paper orientation, paper sizes, and direct access to the printer driver's native properties window (to disable OEM colour management, choose media types, etc.), while eliminating manual DPI scaling in favor of an intelligent automatic page-fit scaler.
Key Requirements & Features
1. Native Printer Driver Properties Dialog Button
Add a "Printer Properties" (or "Driver Preferences") button alongside the printer selector.
Windows: Invoke DocumentPropertiesW (with DM_IN_PROMPT | DM_IN_BUFFER | DM_OUT_BUFFER) or PrinterProperties modally (attached to the Tauri app window handle HWND).
Allows the user to adjust OEM vendor settings (e.g., Epson "No Colour Adjustment", Canon "Off (No Colour Adjustment)", paper thickness, platen gap, vacuum intensity).
Captures the returned DEVMODEW structure and applies it to subsequent print jobs for the session.
macOS / Linux: Provide access to CUPS printer options / PPD media settings (lpoptions or system print options).
2. Media & Page Setup Controls
Provide direct in-app selectors for basic print parameters before spooling:
Paper Size: (e.g., A4, A3, A2, US Letter, US Legal, 4x6, 11x17, Custom) synchronized with printer capabilities.
Paper Source / Tray: (e.g., Auto Sheet Feeder, Front Cassette, Rear Tray, Manual Feed, Roll Paper) queried dynamically from the selected printer.
Orientation: Toggle switch for Portrait and Landscape (dmOrientation / -o landscape).
3. Automatic Behind-the-Scenes Page Fit Scaler
Remove/Replace Manual DPI Dropdown: Remove the manual resolution/DPI scaling dropdown from the user workflow.
Automatic Fit Engine: Implement a smart geometric scaler in the print engine:
Place "Printer Properties" button next to "Destination Printer" and status badge.
Add Media Settings row: Paper Size select, Paper Source / Tray select, Orientation toggle buttons.
Replace the DPI dropdown with an informational badge showing target dimensions & fit status.
Maintain color management warning banners and individual page print buttons.
Acceptance Criteria
Clicking "Printer Properties" launches the native printer driver preferences window on Windows.
User can select Paper Source / Tray and Orientation directly from the UI.
Manual DPI dropdown is replaced with an automatic proportional scaler that fits the target TIFF cleanly into the printable area without patch clipping.
Target is centered on the page and aspect ratio is strictly maintained.
Color management bypass remains 100% enforced (SetICMMode(hdc, ICM_OFF) & raw passthrough).
Settings persist during the session and gracefully handle multi-page target sets.
### Objective
Enhance the **Stage 2: Print Layout & Direct Native Raw Printing** panel with essential print setup controls and an automatic layout scaler. Profiling workflows require precise control over media trays, paper orientation, paper sizes, and direct access to the printer driver's native properties window (to disable OEM colour management, choose media types, etc.), while eliminating manual DPI scaling in favor of an intelligent automatic page-fit scaler.
---
### Key Requirements & Features
#### 1. Native Printer Driver Properties Dialog Button
- Add a **"Printer Properties"** (or **"Driver Preferences"**) button alongside the printer selector.
- **Windows:** Invoke `DocumentPropertiesW` (with `DM_IN_PROMPT | DM_IN_BUFFER | DM_OUT_BUFFER`) or `PrinterProperties` modally (attached to the Tauri app window handle `HWND`).
- Allows the user to adjust OEM vendor settings (e.g., Epson "No Colour Adjustment", Canon "Off (No Colour Adjustment)", paper thickness, platen gap, vacuum intensity).
- Captures the returned `DEVMODEW` structure and applies it to subsequent print jobs for the session.
- **macOS / Linux:** Provide access to CUPS printer options / PPD media settings (`lpoptions` or system print options).
#### 2. Media & Page Setup Controls
Provide direct in-app selectors for basic print parameters before spooling:
- **Paper Size:** (e.g., A4, A3, A2, US Letter, US Legal, 4x6, 11x17, Custom) synchronized with printer capabilities.
- **Paper Source / Tray:** (e.g., Auto Sheet Feeder, Front Cassette, Rear Tray, Manual Feed, Roll Paper) queried dynamically from the selected printer.
- **Orientation:** Toggle switch for **Portrait** and **Landscape** (`dmOrientation` / `-o landscape`).
#### 3. Automatic Behind-the-Scenes Page Fit Scaler
- **Remove/Replace Manual DPI Dropdown:** Remove the manual resolution/DPI scaling dropdown from the user workflow.
- **Automatic Fit Engine:** Implement a smart geometric scaler in the print engine:
- Query device metrics (`HORZRES`, `VERTRES`, `LOGPIXELSX`, `LOGPIXELSY`, `PHYSICALOFFSETX`, `PHYSICALOFFSETY`, `PHYSICALWIDTH`, `PHYSICALHEIGHT`).
- Scale the target TIFF proportionally to fit the maximum printable area of the sheet without clipping borders, patch marks, or registration lines.
- Center the target on the sheet while preserving 100% aspect ratio and strict pixel integrity (no interpolation artefacts or color re-mapping).
---
### Technical Architecture
#### Backend (`src-tauri/src/print/`)
- **Windows (`windows.rs`):**
- Query capabilities with `DeviceCapabilitiesW` (`DC_BINS`, `DC_BINNAMES`, `DC_PAPERS`, `DC_PAPERNAMES`).
- Add `show_printer_properties(printer_name: &str, hwnd: isize)` to display modal driver dialog and retain configured `DEVMODEW`.
- Pass custom `DEVMODEW` into `CreateDCW` during `print_target`.
- Refine `StretchDIBits` destination rect calculation for exact printable bounds fit.
- **Unix / CUPS (`unix.rs`):**
- Query media sources and supported paper sizes via CUPS / PPD options.
- Pass `InputSlot`, `PageSize`, and `orientation-requested` into `lp` options.
- **Tauri Commands (`commands.rs`):**
- `get_printer_capabilities(printer_name: String) -> Result<PrinterCapabilities, String>`
- `open_printer_properties(printer_name: String) -> Result<(), String>`
- Update `print_target_native` to accept structured `PrintOptions` (paper source, orientation, page size).
#### Frontend (`src/index.html`, `src/js/printtarg.js`, `src/styles/main.css`)
- **Stage 2 UI Redesign:**
- Place "Printer Properties" button next to "Destination Printer" and status badge.
- Add Media Settings row: Paper Size select, Paper Source / Tray select, Orientation toggle buttons.
- Replace the DPI dropdown with an informational badge showing target dimensions & fit status.
- Maintain color management warning banners and individual page print buttons.
---
### Acceptance Criteria
- [ ] Clicking **"Printer Properties"** launches the native printer driver preferences window on Windows.
- [ ] User can select Paper Source / Tray and Orientation directly from the UI.
- [ ] Manual DPI dropdown is replaced with an automatic proportional scaler that fits the target TIFF cleanly into the printable area without patch clipping.
- [ ] Target is centered on the page and aspect ratio is strictly maintained.
- [ ] Color management bypass remains 100% enforced (`SetICMMode(hdc, ICM_OFF)` & raw passthrough).
- [ ] Settings persist during the session and gracefully handle multi-page target sets.
gronod
added this to the Milestone 6: Native Raw OS Printing Engine milestone 2026-08-23 20:54:51 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Objective
Enhance the Stage 2: Print Layout & Direct Native Raw Printing panel with essential print setup controls and an automatic layout scaler. Profiling workflows require precise control over media trays, paper orientation, paper sizes, and direct access to the printer driver's native properties window (to disable OEM colour management, choose media types, etc.), while eliminating manual DPI scaling in favor of an intelligent automatic page-fit scaler.
Key Requirements & Features
1. Native Printer Driver Properties Dialog Button
DocumentPropertiesW(withDM_IN_PROMPT | DM_IN_BUFFER | DM_OUT_BUFFER) orPrinterPropertiesmodally (attached to the Tauri app window handleHWND).DEVMODEWstructure and applies it to subsequent print jobs for the session.lpoptionsor system print options).2. Media & Page Setup Controls
Provide direct in-app selectors for basic print parameters before spooling:
dmOrientation/-o landscape).3. Automatic Behind-the-Scenes Page Fit Scaler
HORZRES,VERTRES,LOGPIXELSX,LOGPIXELSY,PHYSICALOFFSETX,PHYSICALOFFSETY,PHYSICALWIDTH,PHYSICALHEIGHT).Technical Architecture
Backend (
src-tauri/src/print/)windows.rs):DeviceCapabilitiesW(DC_BINS,DC_BINNAMES,DC_PAPERS,DC_PAPERNAMES).show_printer_properties(printer_name: &str, hwnd: isize)to display modal driver dialog and retain configuredDEVMODEW.DEVMODEWintoCreateDCWduringprint_target.StretchDIBitsdestination rect calculation for exact printable bounds fit.unix.rs):InputSlot,PageSize, andorientation-requestedintolpoptions.commands.rs):get_printer_capabilities(printer_name: String) -> Result<PrinterCapabilities, String>open_printer_properties(printer_name: String) -> Result<(), String>print_target_nativeto accept structuredPrintOptions(paper source, orientation, page size).Frontend (
src/index.html,src/js/printtarg.js,src/styles/main.css)Acceptance Criteria
SetICMMode(hdc, ICM_OFF)& raw passthrough).