Fix blank PDF by using temporary DOM element for rendering
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user