fix: print PagedJS content via new window

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 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2025-12-08 14:01:27 +01:00
parent bd19369dac
commit ded9744485

View file

@ -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);
}
}
};