- Catalogo: qualità di stampa, margini. ora è 300 DPI.
This commit is contained in:
@@ -2283,6 +2283,56 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
})
|
||||
},
|
||||
|
||||
async execConvertPDF(paramquery: any) {
|
||||
// console.log('paramquery', paramquery)
|
||||
return Api.SendReq('/admin/convert-pdf', 'postFormData', {}, false, false, 1, 5000, paramquery, { responseType: 'blob' })
|
||||
.then((res) => {
|
||||
return res.data
|
||||
}).catch((error) => {
|
||||
return false
|
||||
})
|
||||
},
|
||||
|
||||
async convertPdf(pdfFile: any, width: string, height: string, compressione: string) {
|
||||
try {
|
||||
|
||||
if (!pdfFile) {
|
||||
console.error('No PDF file selected');
|
||||
return;
|
||||
}
|
||||
|
||||
const filenameToDownload = tools.removeFileExtension(pdfFile.name) + '-output.pdf'
|
||||
|
||||
const formData = new FormData();
|
||||
if (pdfFile instanceof File) {
|
||||
formData.append('pdf', pdfFile);
|
||||
}
|
||||
formData.append('width', width); // Dimensione del PDF in cm
|
||||
formData.append('height', height); // Dimensione del PDF in cm
|
||||
formData.append('compressione', compressione);
|
||||
|
||||
const response = await this.execConvertPDF(formData)
|
||||
|
||||
if (response) {
|
||||
const blob = new Blob([response], { type: 'application/pdf' });
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.setAttribute('download', filenameToDownload);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
} else {
|
||||
console.error('No data returned from the server.');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error converting PDF:', error);
|
||||
}
|
||||
},
|
||||
|
||||
async saveServerMysql(paramquery: any) {
|
||||
return Api.SendReq('/admin/mysql', 'POST', paramquery)
|
||||
.then((res) => {
|
||||
|
||||
Reference in New Issue
Block a user