- 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:
@@ -29,6 +29,12 @@ export const useCatalogStore = defineStore('CatalogStore', {
|
||||
getCatalogById: (state) => (id: string): ICatalog => {
|
||||
return state.catalogs.find((cat: ICatalog) => cat._id === id) || null;
|
||||
},
|
||||
|
||||
getCatalogsList: (state) => (): {label: string, value: string}[] => {
|
||||
return state.catalogs.map((cat: ICatalog) => {
|
||||
return {label: cat.title, value: cat._id};
|
||||
});
|
||||
},
|
||||
getCatalogByIdPageAssigned: (state) => (idPage: string): ICatalog => {
|
||||
return state.catalogs.find((cat: ICatalog) => cat.idPageAssigned === idPage) || null;
|
||||
},
|
||||
|
||||
@@ -366,7 +366,6 @@ export const colmyScheda = [
|
||||
AddCol({ name: 'isTemplate', label_trans: 'scheda.isTemplate', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'isPagIntro', label_trans: 'scheda.isPagIntro', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'linkIdTemplate', label_trans: 'scheda.linkIdTemplate', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'linkIdTemplatePerStampa', label_trans: 'scheda.linkIdTemplatePerStampa', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'widthscheda', label_trans: 'scheda.widthscheda', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'widthpag', label_trans: 'scheda.widthpag', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'widthimg', label_trans: 'scheda.widthimg', fieldtype: costanti.FieldType.number }),
|
||||
@@ -581,6 +580,7 @@ export const colmypage = [
|
||||
AddCol({ name: 'internalpage', label_trans: 'pages.internalpage', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'loadFirst', label_trans: 'pages.loadFirst', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'showFooter', label_trans: 'pages.showFooter', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'hideHeader', label_trans: 'pages.hideHeader', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'iconsize', label_trans: 'pages.iconsize', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'extraclass', label_trans: 'pages.extraclass', fieldtype: costanti.FieldType.string }),
|
||||
AddCol(DeleteRec),
|
||||
|
||||
@@ -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 !
|
||||
|
||||
|
||||
@@ -1890,7 +1890,8 @@ export const useProducts = defineStore('Products', {
|
||||
'{formato}',
|
||||
'{tipologia}',
|
||||
'{stato}',
|
||||
'{scale}',
|
||||
'{scalex}',
|
||||
'{scaley}',
|
||||
'{descr_trafiletto_catalogo}',
|
||||
'{link_macro}',
|
||||
'{qta}',
|
||||
@@ -1973,8 +1974,11 @@ export const useProducts = defineStore('Products', {
|
||||
myproduct.productInfo?.idStatoProdotto || ''
|
||||
)
|
||||
break
|
||||
case '{scale}':
|
||||
replacements[key] = optcatalogo.printable ? optcatalogo.areadistampa?.scale : '1'
|
||||
case '{scalex}':
|
||||
replacements[key] = optcatalogo.printable ? optcatalogo.areadistampa?.scalex : '1'
|
||||
break
|
||||
case '{scaley}':
|
||||
replacements[key] = optcatalogo.printable ? optcatalogo.areadistampa?.scaley : '1'
|
||||
break
|
||||
case '{link_macro}':
|
||||
replacements[key] = myproduct.productInfo.link_macro || ''
|
||||
@@ -2362,10 +2366,7 @@ export const useProducts = defineStore('Products', {
|
||||
if (optcatalogo) {
|
||||
try {
|
||||
// LINK PAGINA
|
||||
let idLinkTempl =
|
||||
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
|
||||
? optcatalogo.dimensioni_def.linkIdTemplatePerStampa
|
||||
: optcatalogo.dimensioni_def.linkIdTemplate
|
||||
let idLinkTempl =optcatalogo.dimensioni_def.linkIdTemplate
|
||||
if (idLinkTempl) {
|
||||
const reccatalog = globalStore.sovrascriviPaginaDefaultFromTemplate(
|
||||
idLinkTempl,
|
||||
@@ -2378,10 +2379,7 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
}
|
||||
|
||||
let idLinkPr =
|
||||
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
|
||||
? optcatalogo.print_linkIdTemplatePerStampa
|
||||
: optcatalogo.print_linkIdTemplate
|
||||
let idLinkPr = optcatalogo.print_linkIdTemplate
|
||||
|
||||
if (idLinkPr) {
|
||||
const reccat2 = globalStore.sovrascriviAreadistampaFromTemplate(idLinkPr, optcatalogo)
|
||||
@@ -2390,10 +2388,13 @@ export const useProducts = defineStore('Products', {
|
||||
// optcatalogo2.areadistampa = { ...reccat2.areadistampa};
|
||||
optcatalogo2.areadistampa.margini = reccat2.areadistampa.margini
|
||||
optcatalogo2.areadistampa.unit = reccat2.areadistampa.unit
|
||||
optcatalogo2.areadistampa.scale = reccat2.areadistampa.scale
|
||||
optcatalogo2.areadistampa.scalex = reccat2.areadistampa.scalex
|
||||
optcatalogo2.areadistampa.scaley = reccat2.areadistampa.scaley
|
||||
optcatalogo2.areadistampa.scalecanvas = reccat2.areadistampa.scalecanvas
|
||||
optcatalogo2.areadistampa.scale_printable = reccat2.areadistampa.scale_printable
|
||||
optcatalogo2.areadistampa.scale_printablex = reccat2.areadistampa.scale_printablex
|
||||
optcatalogo2.areadistampa.scale_printabley = reccat2.areadistampa.scale_printabley
|
||||
optcatalogo2.areadistampa.format = reccat2.areadistampa.format
|
||||
optcatalogo2.areadistampa.format_printable = reccat2.areadistampa.format_printable
|
||||
optcatalogo2.areadistampa.orientation = reccat2.areadistampa.orientation
|
||||
optcatalogo2.areadistampa.compress = reccat2.areadistampa.compress
|
||||
|
||||
@@ -2404,11 +2405,7 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
|
||||
for (const recscheda of optcatalogo.arrSchede!) {
|
||||
let idtempl =
|
||||
optcatalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA &&
|
||||
recscheda.scheda?.linkIdTemplatePerStampa
|
||||
? recscheda.scheda?.linkIdTemplatePerStampa
|
||||
: recscheda.scheda?.linkIdTemplate
|
||||
let idtempl =recscheda.scheda?.linkIdTemplate
|
||||
if (idtempl) {
|
||||
// ricopia da Template:
|
||||
let myscheda = globalStore.sovrascriviSchedaFromTemplate(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,6 +60,7 @@ async function getConfig(id: any) {
|
||||
|
||||
export const useGlobalStore = defineStore('GlobalStore', {
|
||||
state: (): IGlobalState => ({
|
||||
showHeader: true,
|
||||
finishLoading: false,
|
||||
conta: 0,
|
||||
wasAlreadySubscribed: false,
|
||||
@@ -230,9 +231,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
myschedatocopy.scheda._id = origScheda.scheda?._id;
|
||||
myschedatocopy.scheda.isTemplate = false;
|
||||
myschedatocopy.scheda.name = precname;
|
||||
myschedatocopy.scheda.linkIdTemplatePerStampa =
|
||||
origScheda.scheda?.linkIdTemplatePerStampa;
|
||||
myschedatocopy.scheda.linkIdTemplate = origScheda.scheda?.linkIdTemplate;
|
||||
myschedatocopy.scheda.scalexscheda = origScheda.scheda?.scalexscheda;
|
||||
myschedatocopy.scheda.scaleyscheda = origScheda.scheda?.scaleyscheda;
|
||||
|
||||
return myschedatocopy.scheda;
|
||||
}
|
||||
@@ -254,8 +255,6 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
// myelemtocopy.scheda._id = origScheda.scheda?._id;
|
||||
myelemtocopy.catalogo.dimensioni_def.isTemplate = false;
|
||||
myelemtocopy.catalogo.dimensioni_def.name = precname;
|
||||
myelemtocopy.catalogo.dimensioni_def.linkIdTemplatePerStampa =
|
||||
origDimensioni.linkIdTemplatePerStampa;
|
||||
myelemtocopy.catalogo.dimensioni_def.linkIdTemplate = origDimensioni.linkIdTemplate;
|
||||
|
||||
return myelemtocopy.catalogo;
|
||||
@@ -273,19 +272,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
const myelemtocopy = tools.jsonCopy(myfindelem);
|
||||
|
||||
if (myelemtocopy) {
|
||||
const linkIdTemplate =
|
||||
myelemtocopy.catalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
|
||||
? myelemtocopy.catalogo.print_linkIdTemplate
|
||||
: myelemtocopy.catalogo.print_linkIdTemplatePerStampa;
|
||||
// myelemtocopy.scheda._id = origScheda.scheda?._id;
|
||||
const linkIdTemplate = myelemtocopy.catalogo.print_linkIdTemplate
|
||||
myelemtocopy.catalogo.print_isTemplate = false;
|
||||
if (
|
||||
myelemtocopy.catalogo.selectedVersionStampabile === shared_consts.PREPARA_PDF.STAMPA
|
||||
)
|
||||
myelemtocopy.catalogo.print_linkIdTemplatePerStampa = linkIdTemplate;
|
||||
else {
|
||||
myelemtocopy.catalogo.print_linkIdTemplate = linkIdTemplate;
|
||||
}
|
||||
myelemtocopy.catalogo.print_linkIdTemplate = linkIdTemplate;
|
||||
|
||||
return myelemtocopy.catalogo;
|
||||
}
|
||||
@@ -2615,6 +2604,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
createCatalogoVuoto(): IOptCatalogo {
|
||||
return {
|
||||
idCatalogSel: '',
|
||||
productTypes: [0],
|
||||
excludeproductTypes: [],
|
||||
idTipologie: [],
|
||||
@@ -2625,14 +2615,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
dimensioni_def: {
|
||||
isTemplate: false,
|
||||
linkIdTemplate: '',
|
||||
linkIdTemplatePerStampa: '',
|
||||
name: '',
|
||||
pagina: tools.resetRecIDimensioni(null),
|
||||
},
|
||||
areadistampa: tools.resetRecIAreaDiStampa(null),
|
||||
print_isTemplate: false,
|
||||
print_linkIdTemplate: '',
|
||||
print_linkIdTemplatePerStampa: '',
|
||||
};
|
||||
},
|
||||
createRaccoltaCataloghiVuoto(): IOptCatalogo {
|
||||
@@ -2647,14 +2635,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
dimensioni_def: {
|
||||
isTemplate: false,
|
||||
linkIdTemplate: '',
|
||||
linkIdTemplatePerStampa: '',
|
||||
name: '',
|
||||
pagina: tools.resetRecIDimensioni(null),
|
||||
},
|
||||
areadistampa: tools.resetRecIAreaDiStampa(null),
|
||||
print_isTemplate: false,
|
||||
print_linkIdTemplate: '',
|
||||
print_linkIdTemplatePerStampa: '',
|
||||
};
|
||||
},
|
||||
|
||||
@@ -3086,5 +3072,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
setshowHeader(value: boolean) {
|
||||
this.showHeader = value
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user