From ded974448574b56ae94b520259666f2f14d172cf Mon Sep 17 00:00:00 2001 From: isUnknown Date: Mon, 8 Dec 2025 14:01:27 +0100 Subject: [PATCH] fix: print PagedJS content via new window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Open iframe content in a new window for printing to avoid blank page issues with srcdoc iframes. The window opens, prints, then closes automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/App.vue | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/App.vue b/src/App.vue index 05c4189..38a69d1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -279,8 +279,28 @@ const handlePrint = (event) => { if ((event.metaKey || event.ctrlKey) && event.key === 'p') { event.preventDefault(); const frame = activeFrame.value; - if (frame && frame.contentWindow) { - frame.contentWindow.print(); + if (frame && frame.contentDocument) { + // Get the full HTML content of the iframe + const content = frame.contentDocument.documentElement.outerHTML; + + // Open a new window with the content + const printWindow = window.open('', '_blank'); + printWindow.document.write(content); + printWindow.document.close(); + + // Wait for content to load then print + printWindow.onload = () => { + printWindow.print(); + printWindow.close(); + }; + + // Fallback if onload doesn't fire + setTimeout(() => { + if (!printWindow.closed) { + printWindow.print(); + printWindow.close(); + } + }, 500); } } };