A poster printed from a phone is exactly one page (its print root is sized and clipped to the fitted sheet), and its leader lines match the image print's weight

This commit is contained in:
Doxa Maps 2026-10-03 15:56:04 +00:00
parent fc3b48425d
commit c2e20fb682

View file

@ -867,8 +867,13 @@ function fitForPrint(html) {
const M = (PRINT_MARGIN_MM / 25.4) * 96 const M = (PRINT_MARGIN_MM / 25.4) * 96
const W = +box[1], H = +box[2] const W = +box[1], H = +box[2]
const f = Math.min((pageW - 2 * M) / W, (pageH - 2 * M) / H) * 0.995 const f = Math.min((pageW - 2 * M) / W, (pageH - 2 * M) / H) * 0.995
const w = Math.floor(W * f), h = Math.floor(H * f)
// On a PHONE the sheet prints inside the page itself (printInPlace's #dxm-print-root), where the host's print rules
// force html/body overflow visible, so the stage's unscaled layout box spilled onto blank pages: the root is sized
// and clipped to the fitted box too (the frame print has no root, so this rule changes nothing there).
const css = `<style>@media print{@page{margin:${PRINT_MARGIN_MM}mm}.stage{transform:scale(${(+sc[1] * f).toFixed(6)})}` const css = `<style>@media print{@page{margin:${PRINT_MARGIN_MM}mm}.stage{transform:scale(${(+sc[1] * f).toFixed(6)})}`
+ `html,body{width:${Math.floor(W * f)}px;height:${Math.floor(H * f)}px}.lead{stroke-opacity:.55}.slead{opacity:.35}}</style>` + `html,body{width:${w}px;height:${h}px}#dxm-print-root{width:${w}px!important;height:${h}px!important;overflow:hidden!important;margin:0!important}`
+ `.lead{stroke-opacity:.75}.slead{opacity:.5}}</style>`
return html.replace('</head>', css + '</head>') return html.replace('</head>', css + '</head>')
} }