From 902befa189dad04b31f9740cd8163d9faf49a84a Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Wed, 27 May 2026 13:53:36 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20blank=20PDF=20print=20regression=20?= =?UTF-8?q?=E2=80=94=20split=20exporting=20/=20export-print=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recent commit 119b14e added body.classList.add('export-print') to the regular print flow (printWithCurrentFilename) to strip selection chrome from the output. That broke PDF print entirely because an existing @media print rule — body.export-print > *:not(#exportPrintContainer):not(#globalClipDefs) { display: none !important; } — hides every direct body child when body.export-print is set. The JPEG-PDF flow first reparents the sheet into #exportPrintContainer (enterExportPrintMode), so that rule isolates the sheet correctly. The regular print flow doesn't reparent anything, so the rule just hid the entire .app and printed a blank page. Fix: two classes with separate responsibilities. - `body.exporting` — chrome stripping only (selection outlines, resize handles, layer selection box, canvasVeil, color-adjust hints). Safe to apply during any print/export, because nothing hides the document. - `body.export-print` — also reparents the sheet into #exportPrintContainer. Only the JPEG-PDF flow does this setup. Wiring: - printWithCurrentFilename adds/removes body.exporting (no export-print) — PDF print path now renders the live DOM with only chrome stripped. - enterExportPrintMode adds both classes; exitExportPrintMode removes both. - CSS chrome-stripping rules renamed from body.export-print → body.exporting (the existing body.export-print container-isolation rules at line 2588+ stay as they were). Verified via CDP Page.printToPDF on customart mode: PDF is 1 page at 960×540 pts (= 1280×720 px at 72 pt/in), text content "Print Test" extracts, color block + crop marks render, and the selected-layer outline is no longer visible (was visible before my chrome-stripping rules existed; still working now). Co-Authored-By: Claude Opus 4.7 --- src/index.html | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/index.html b/src/index.html index 013d058..274551a 100644 --- a/src/index.html +++ b/src/index.html @@ -2463,23 +2463,23 @@ generating output via window.print(). It strips editor chrome from the snapshot so the PDF / JPEG-fallback doesn't include layer selection outlines, resize handles, the spine guide labels, etc. */ - body.export-print .spineText, body.export-print .discSpineStrip { + body.exporting .spineText, body.exporting .discSpineStrip { display: none !important; } - body.export-print .freeLayer.selected, - body.export-print .freeLayer.multiSelected { + body.exporting .freeLayer.selected, + body.exporting .freeLayer.multiSelected { outline: none !important; box-shadow: none !important; } - body.export-print .layerHandle, - body.export-print .layerSelectionBox { display: none !important; } - body.export-print .freeLayer { + body.exporting .layerHandle, + body.exporting .layerSelectionBox { display: none !important; } + body.exporting .freeLayer { pointer-events: none !important; } - body.export-print .sheet, - body.export-print .sheet *, - body.export-print .designerDiscWrap, - body.export-print .designerDiscWrap * { + body.exporting .sheet, + body.exporting .sheet *, + body.exporting .designerDiscWrap, + body.exporting .designerDiscWrap * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; @@ -14798,10 +14798,15 @@ function printWithCurrentFilename() { const previousTitle = document.title; const nextTitle = currentPdfTitle(); - document.body.classList.add('export-print'); + // `exporting` (chrome-stripping only) is safe for the regular print + // path which renders the live DOM as-is. The heavier `export-print` + // class triggers a CSS rule that hides everything outside + // #exportPrintContainer — only the JPEG-PDF flow sets that up, so + // adding it here would print a blank page. + document.body.classList.add('exporting'); const restore = () => { document.title = previousTitle; - document.body.classList.remove('export-print'); + document.body.classList.remove('exporting'); window.removeEventListener('afterprint', restore); }; window.addEventListener('afterprint', restore); @@ -21645,6 +21650,7 @@ container.appendChild(sheet); sheet.style.cssText = `position:absolute!important;top:${fmt(offsetY)}in!important;left:${fmt(offsetX)}in!important;width:${fmt(sheetW())}in!important;height:${fmt(sheetH())}in!important;margin:0!important;padding:0!important;transform:none!important;box-shadow:none!important;${bg ? `background:${bg}!important;` : ''}`; document.body.classList.add('export-print'); + document.body.classList.add('exporting'); $('dynamicPageStyle').textContent = `@page { size: ${fmt(pageWIn)}in ${fmt(pageHIn)}in; margin: 0; }`; return true; } @@ -21664,6 +21670,7 @@ } container.remove(); document.body.classList.remove('export-print'); + document.body.classList.remove('exporting'); _exportSheetOrigParent = null; _exportSheetOrigNext = null; _exportSheetOrigStyle = null;