This commit is contained in:
LORENZO\pacio 2025-07-22 09:48:19 +02:00
parent a9a8a60bbf
commit ce839f1d07
5 changed files with 44 additions and 12 deletions

View File

@ -204,7 +204,7 @@ function capitalizeEachWord(str) {
} }
function exportPdf(filename = 'certificato-prova.pdf') { /*function exportPdf(filename = 'certificato-prova.pdf') {
html2pdf() html2pdf()
.from(printable.value) .from(printable.value)
.set({ .set({
@ -217,8 +217,43 @@ function exportPdf(filename = 'certificato-prova.pdf') {
} }
}) })
.save() .save()
}*/
function exportPdf(filename = 'certificato-prova.pdf') {
const opt = {
margin: 0,
filename,
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: [210, 297], orientation: 'portrait' },
pagebreak: { mode: ['css','legacy'] }
};
html2pdf()
.set(opt)
.from(printable.value)
.toPdf()
.get('pdf')
.then(pdf => {
const totalPages = pdf.internal.getNumberOfPages();
const pageWidth = pdf.internal.pageSize.getWidth();
const pageHeight = pdf.internal.pageSize.getHeight();
for (let i = 1; i <= totalPages; i++) {
pdf.setPage(i);
pdf.setFontSize(9);
pdf.text(
`Pagina ${i} di ${totalPages}`,
pageWidth / 2,
pageHeight - 8, // 8mm up from bottom
{ align: 'center' }
);
}
})
.save();
} }
function formatDate(dateStr) { function formatDate(dateStr) {
const date = new Date(dateStr) const date = new Date(dateStr)
return date.toLocaleDateString('it-IT') return date.toLocaleDateString('it-IT')
@ -324,9 +359,6 @@ header {
margin-top: 16px; margin-top: 16px;
margin-bottom: 2px; margin-bottom: 2px;
text-align: center; text-align: center;
white-space: pre-wrap; /* preserves newlines */
word-break: break-word; /* wraps long lines if needed */
} }
.sub-header { .sub-header {

View File

@ -25,8 +25,8 @@
<!-- RISULTATI --> <!-- RISULTATI -->
<div class="section-title">{{ intestazione.prova1 }}</div> <div class="section-title" v-html="intestazione.prova1"></div>
<div class="sub-header">{{ intestazione.prova2 }}</div> <div class="sub-header" v-html="intestazione.prova2"></div>
<table> <table>
<thead> <thead>
<tr> <tr>

View File

@ -25,8 +25,8 @@
<!-- RISULTATI --> <!-- RISULTATI -->
<div class="section-title">{{ intestazione.prova1 }}</div> <div class="section-title" v-html="intestazione.prova1"></div>
<div class="sub-header">{{ intestazione.prova2 }}</div> <div class="sub-header" v-html="intestazione.prova2"></div>
<table> <table>
<thead> <thead>
<tr> <tr>

View File

@ -39,8 +39,8 @@
<!-- RISULTATI --> <!-- RISULTATI -->
<div class="section-title">{{ intestazione.prova1 }}</div> <div class="section-title" v-html="intestazione.prova1"></div>
<div class="sub-header">{{ intestazione.prova2 }}</div> <div class="sub-header" v-html="intestazione.prova2"></div>
<table> <table>
<thead> <thead>
<tr> <tr>

View File

@ -39,8 +39,8 @@
<!-- RISULTATI --> <!-- RISULTATI -->
<div class="section-title">{{ intestazione.prova1 }}</div> <div class="section-title" v-html="intestazione.prova1"></div>
<div class="sub-header">{{ intestazione.prova2 }}</div> <div class="sub-header" v-html="intestazione.prova2"></div>
<table> <table>
<thead> <thead>
<tr> <tr>