Fix blank PDF by using temporary DOM element for rendering

This commit is contained in:
Felix Brabetz
2026-05-16 06:46:40 +02:00
parent a431237b70
commit d5d7645b47
+10 -1
View File
@@ -60,8 +60,17 @@ function downloadPDF(elementId, title) {
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
// Create temporary element
const worker = document.createElement('div');
worker.innerHTML = html;
worker.style.position = 'absolute';
worker.style.left = '-9999px';
document.body.appendChild(worker);
// PDF generieren
html2pdf().set(opt).from(html).save();
html2pdf().set(opt).from(worker).save().then(() => {
document.body.removeChild(worker);
});
}
</script>