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:
parent
bd19369dac
commit
ded9744485
1 changed files with 22 additions and 2 deletions
24
src/App.vue
24
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue