fix: add PDF export fallback when client render fails
This commit is contained in:
@@ -499,7 +499,13 @@ function closeAiModal(){
|
||||
|
||||
async function downloadPdf(){
|
||||
if (!window.html2canvas || !window.jspdf?.jsPDF) {
|
||||
alert('PDF-Export-Bibliothek nicht geladen.');
|
||||
alert('PDF-Export-Bibliothek nicht geladen. Nutze Fallback-Druckdialog.');
|
||||
const printWin = window.open('', '_blank');
|
||||
if (printWin) {
|
||||
printWin.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>Coachingcards PDF</title></head><body>${app.innerHTML}</body></html>`);
|
||||
printWin.document.close();
|
||||
printWin.onload = () => setTimeout(() => printWin.print(), 200);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -553,6 +559,15 @@ async function downloadPdf(){
|
||||
}
|
||||
|
||||
pdf.save(`coachingcards-${new Date().toISOString().slice(0,10)}.pdf`);
|
||||
} catch (e) {
|
||||
console.error('PDF export failed', e);
|
||||
alert('PDF-Export fehlgeschlagen – öffne Druckdialog als Fallback.');
|
||||
const printWin = window.open('', '_blank');
|
||||
if (printWin) {
|
||||
printWin.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>Coachingcards PDF</title></head><body>${app.innerHTML}</body></html>`);
|
||||
printWin.document.close();
|
||||
printWin.onload = () => setTimeout(() => printWin.print(), 200);
|
||||
}
|
||||
} finally {
|
||||
root.remove();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user