feat(print): add native printing and restore reading state #12

Open
opened 2026-10-11 05:59:08 +00:00 by KofTwentyTwo · 1 comment
KofTwentyTwo commented 2026-10-11 05:59:08 +00:00 (Migrated from github.com)

Implement the Windows equivalent of pinned markdownViewr printing (reference 6d08bc9d27d7d7b2c2fa95bb282da330b8cf9021, ContentView.swift PrintCoordinator/PrintScriptGenerator and printActiveDocument).

Required behavior:

  • Deliberate native File/Print and Ctrl+P, available only for a committed ready document; Windows print UI and normal cancellation/error handling.
  • Saved print theme: Clean Printing by default, Active Theme, Plain HTML or a selected built-in/user theme.
  • Backgrounds off and images on by default; Standard (100%) or Match Screen zoom; Full Page versus document content width; optional borders and bounded page padding. Preserve the reference choices while mapping native Windows units deliberately.
  • Restore screen theme/CSS, reading zoom/position, outline/collapse/source/find state after success, cancellation or failure. Never leave print-only classes/padding behind; do not mutate canonical document content.
  • Preserve the isolated document/resource policy: no authored script, bridge, unbounded native messages, arbitrary path access or remote fetches. No private document text/path logs.

Acceptance must inspect actual printed output (owned fixture PDF/native rendering) for theme, image/background/width/border/padding/zoom behavior and actual unchanged screen state after cancellation/success. Native-dialog acceptance must use the hosted Windows desktop or an explicitly reserved local desktop; core tests alone are insufficient. Printing tests must not send jobs to a user's physical printer. Keep 100% measured core coverage, zero-warning build, format, existing hostile-content/live reload/source/find/vim tests and both installed-channel gates.

Use published AppKit 0.1.0 and the repository's pinned WebView2 API. ShowPrintUI returns no completion task; choose a lifecycle that proves restoration rather than restoring immediately after opening a still-live print dialog. Inspect actual SDK/native APIs before finalizing the design, preserve Darin's MIT attribution and update the threat model/ADR as required. This issue tracks implementation, not a declaration of completed printing.

Refs #1.

API audit: Microsoft's printing overview distinguishes void ShowPrintUI from async Print/PrintToPdf operations. The pinned reference uses a modal completion coordinator to restore screen CSS; do not copy that lifetime onto void ShowPrintUI. Experiment with print-only media CSS so screen styles remain independent, then prove actual output and cancellation. This is a proposed experiment, not a finalized print implementation.

Implement the Windows equivalent of pinned markdownViewr printing (reference 6d08bc9d27d7d7b2c2fa95bb282da330b8cf9021, ContentView.swift PrintCoordinator/PrintScriptGenerator and printActiveDocument). Required behavior: - Deliberate native File/Print and Ctrl+P, available only for a committed ready document; Windows print UI and normal cancellation/error handling. - Saved print theme: Clean Printing by default, Active Theme, Plain HTML or a selected built-in/user theme. - Backgrounds off and images on by default; Standard (100%) or Match Screen zoom; Full Page versus document content width; optional borders and bounded page padding. Preserve the reference choices while mapping native Windows units deliberately. - Restore screen theme/CSS, reading zoom/position, outline/collapse/source/find state after success, cancellation or failure. Never leave print-only classes/padding behind; do not mutate canonical document content. - Preserve the isolated document/resource policy: no authored script, bridge, unbounded native messages, arbitrary path access or remote fetches. No private document text/path logs. Acceptance must inspect actual printed output (owned fixture PDF/native rendering) for theme, image/background/width/border/padding/zoom behavior and actual unchanged screen state after cancellation/success. Native-dialog acceptance must use the hosted Windows desktop or an explicitly reserved local desktop; core tests alone are insufficient. Printing tests must not send jobs to a user's physical printer. Keep 100% measured core coverage, zero-warning build, format, existing hostile-content/live reload/source/find/vim tests and both installed-channel gates. Use published AppKit 0.1.0 and the repository's pinned WebView2 API. ShowPrintUI returns no completion task; choose a lifecycle that proves restoration rather than restoring immediately after opening a still-live print dialog. Inspect actual SDK/native APIs before finalizing the design, preserve Darin's MIT attribution and update the threat model/ADR as required. This issue tracks implementation, not a declaration of completed printing. Refs #1. API audit: [Microsoft's printing overview](https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/print?tabs=dotnetcsharp) distinguishes void ShowPrintUI from async Print/PrintToPdf operations. The pinned reference uses a modal completion coordinator to restore screen CSS; do not copy that lifetime onto void ShowPrintUI. Experiment with print-only media CSS so screen styles remain independent, then prove actual output and cancellation. This is a proposed experiment, not a finalized print implementation.
KofTwentyTwo commented 2026-10-11 08:21:07 +00:00 (Migrated from github.com)

Full printing bf4fcdc / CI38128311242 passes 54 native/published and53 installed stable/dev, zero failures/skips. All5 Print_ cases pass in every build: keyboard draft/Windows dialog cancellation, real default/themed image/background output, exact nonzero reading/source/collapse restoration, standard/matching printed font ratios,40px padding,240px width/full-page edges/borders and preserved paired find/source selection after successful PDFs. 24 actual PDFs/48 PNGs/TRXs retained under artifacts/print-font-verified-installed-38128311242; native log artifacts/print-font-native-38128311242.log.

The traced failure was an incorrect exact ratio from rounded UIA text boxes (35px to44px at121%). Corrected case retains actual screen growth/completed zoom and precise ratios in real printed glyphs; no PDF/state assertion removed. Both actual AppKit apply/restart probes reach expected stable/dev versions without errors; fixtures remain unsigned.

Native window/picker/recents increment e48a08c/checkpoint1cfc07f is now pushed.376 core/100%, build/format/docs/hooks pass; full current CI38129552334 pending57/56. Proposed ADR-0003 still requires maintainer review. No production signing, physical printer job, merge/tag/release or fabricated human review is claimed.

Full printing `bf4fcdc` / CI38128311242 passes **54 native/published and53 installed stable/dev**, zero failures/skips. **All5 Print_ cases pass in every build**: keyboard draft/Windows dialog cancellation, real default/themed image/background output, exact nonzero reading/source/collapse restoration, standard/matching printed font ratios,40px padding,240px width/full-page edges/borders and preserved paired find/source selection after successful PDFs. **24 actual PDFs/48 PNGs/TRXs** retained under `artifacts/print-font-verified-installed-38128311242`; native log `artifacts/print-font-native-38128311242.log`. The traced failure was an incorrect exact ratio from rounded UIA text boxes (35px to44px at121%). Corrected case retains actual screen growth/completed zoom and precise ratios in real printed glyphs; no PDF/state assertion removed. Both actual AppKit apply/restart probes reach expected stable/dev versions without errors; fixtures remain unsigned. Native window/picker/recents increment e48a08c/checkpoint1cfc07f is now pushed.376 core/100%, build/format/docs/hooks pass; full current CI38129552334 pending57/56. Proposed ADR-0003 still requires maintainer review. No production signing, physical printer job, merge/tag/release or fabricated human review is claimed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/MarkdownViewr.Windows#12