fix: add PDF export fallback when client render fails

This commit is contained in:
2026-03-08 10:39:13 +01:00
parent 8b9c878132
commit 5f5250cbee

View File

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