- generazione del PDF riscritto totalmente

- ora è possibile generarlo anche da backend
- FIX: corretto la qualità del PDF e la dimensione non esatta in pixel...
This commit is contained in:
Surya Paolo
2025-05-29 18:23:02 +02:00
parent 884afe4eb5
commit 67aaf719f4
32 changed files with 2881 additions and 1748 deletions

View File

@@ -410,7 +410,8 @@ export const tools = {
SelectListFormatPDF: [
{ label: 'a4 (210x297) (mm) 793x1121 px', value: [210, 297] },
{ label: 'STAMPA con Bordi: 22.53 x 31.25 96 DPI (in mm) 852x1181 px', value: [225.3, 312.5] },
{ label: 'STAMPA con Bordi: 22.53 x 31.26 96 DPI (in mm) 852x1181 px', value: [225.3, 312.6] },
{ label: 'STAMPA MODIF: 22.533 x 31.23 96 DPI (in mm) 852x1181 px', value: [225.33, 312.23] },
],
SelectListScalePDF: [
@@ -10112,7 +10113,8 @@ export const tools = {
compress: false,
orientation: 'portrait',
format: [210, 297],
scale: 1,
scalex: 1,
scaley: 1,
scalecanvas: 2,
};
} else {
@@ -10124,7 +10126,64 @@ export const tools = {
return myrec;
},
adjustSize(optcatalogo: IOptCatalogo, mysize: any, add: number = 0) {
getScaleX(optcatalogo: IOptCatalogo, scheda?: ISchedaSingola, options?: any): number | undefined {
let scalex = 1;
if (
optcatalogo.printable &&
optcatalogo.generazionePDFInCorso &&
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
) {
scalex = optcatalogo.areadistampa?.scale_printablex || 1;
let scaledifftrawebeStampax =
optcatalogo.areadistampa.format[0] / optcatalogo.areadistampa.format_printable[0];
if (!options?.parteesternafissa) scalex *= 1;
else scalex *= 1 / scaledifftrawebeStampax;
} else {
scalex = optcatalogo.areadistampa!.scalex || 1;
}
if (scheda) {
scalex *= scheda.scalex || 1;
}
return scalex;
},
getScaleY(optcatalogo: IOptCatalogo, scheda?: ISchedaSingola, options?: any): number | undefined {
let scaley = 1;
if (
optcatalogo.printable &&
optcatalogo.generazionePDFInCorso &&
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
) {
scaley = optcatalogo.areadistampa?.scale_printabley || 1;
let scaledifftrawebeStampay =
optcatalogo.areadistampa.format[1] / optcatalogo.areadistampa.format_printable[1];
if (!options?.parteesternafissa) scaley *= 1;
else scaley *= 1 / scaledifftrawebeStampay;
} else {
scaley = optcatalogo.areadistampa!.scaley || 1;
}
if (scheda) {
scaley *= scheda?.scaley || 1;
}
return scaley;
},
adjustSize(
optcatalogo: IOptCatalogo,
mysize: any,
scheda: ISchedaSingola,
isX: boolean,
options: any,
add: number = 0
) {
if (!mysize) {
return '';
}
@@ -10140,12 +10199,43 @@ export const tools = {
size += add;
}
let myscale = 1;
if (isX) myscale = this.getScaleX(optcatalogo, scheda, options);
else myscale = this.getScaleY(optcatalogo, scheda, options);
// Applica lo scale della Scheda
size = size * myscale;
if (
optcatalogo.printable &&
optcatalogo.areadistampa?.scale &&
optcatalogo.areadistampa?.scale > 0
optcatalogo.generazionePDFInCorso &&
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
) {
size = size * optcatalogo.areadistampa?.scale; // Applicare la scala se necessaria
let scaledifftrawebeStampax =
optcatalogo.areadistampa.format[0] / optcatalogo.areadistampa.format_printable[0];
let scaledifftrawebeStampay =
optcatalogo.areadistampa.format[1] / optcatalogo.areadistampa.format_printable[1];
const myPaddingPag = optcatalogo.dimensioni_def.pagina.size;
const numwidth = parseFloat(myPaddingPag.width) || 0;
const numheight = parseFloat(myPaddingPag.height) || 0;
const margineX = (((numwidth) * (1/scaledifftrawebeStampax)) - numwidth) / 2;
const marginey = (((numheight) * (1/scaledifftrawebeStampay)) - numheight) / 2;
if (options?.paddingLeft) {
size += marginex;
}
if (options?.paddingRight) {
size -= marginex;
}
if (options?.paddingTop) {
size += marginey;
}
if (options?.paddingBottom) {
size -= marginey;
}
}
const strfinale = `${size}${unit}`;
@@ -10222,12 +10312,6 @@ export const tools = {
return jsonResult;
},
getScale(optcatalogo: IOptCatalogo, instampa: boolean = false): number | undefined {
if ((optcatalogo.printable && optcatalogo.generazionePDFInCorso) || instampa)
return optcatalogo.areadistampa?.scale_printable;
else return optcatalogo.areadistampa!.scale;
},
getMainLink(url: string): string {
try {
// Se l'URL non ha un protocollo, aggiunge "https://"
@@ -10591,7 +10675,7 @@ export const tools = {
getFileCompresso(filename: string) {
return this.removeFileExtension(filename) + `_compressed.pdf`;
}
},
// FINE !