mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
24 lines
940 B
JavaScript
24 lines
940 B
JavaScript
$(() => {
|
|
const elementToPdf = document.querySelector('body'); // o .pdf-wrapper si quieres acotar
|
|
|
|
const opt = {
|
|
margin: 2, // un margen decente
|
|
filename: $(".pdf-wrapper").data("id") + ".pdf",
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: {
|
|
scale: 4,
|
|
useCORS: true,
|
|
scrollY: -window.scrollY, // importante
|
|
//windowWidth: document.body.scrollWidth,
|
|
//windowHeight: document.body.scrollHeight
|
|
},
|
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
|
pagebreak: {
|
|
mode: ['css', 'legacy'], // intenta usar los saltos naturales
|
|
before: '.page-break', // puedes insertar <div class="page-break"></div> si lo necesitas
|
|
avoid: ['table', 'tr', '.row'] // evita cortar tablas
|
|
}
|
|
};
|
|
|
|
html2pdf().set(opt).from(elementToPdf).toPdf().get('pdf').save();
|
|
}); |