- Aggiunta della copertina iniziale nelle raccolte (Catalogo Generale).
- Corretto altezza delle immagini che erano stretchate. - Fix: poter spostare l'ordinamento dei libri corretto.
This commit is contained in:
@@ -32,6 +32,8 @@ const RaccoltaCataloghiSchema = new Schema({
|
||||
type: String,
|
||||
},
|
||||
|
||||
pdf_copertina: IImg,
|
||||
|
||||
nomefile_da_generare: String,
|
||||
|
||||
pdf_generato: String,
|
||||
|
||||
@@ -614,8 +614,6 @@ async function ConvertPDF_Generatore(options, instampa) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
router.post('/online-pdf', authenticate, async (req, res) => {
|
||||
console.log('/online-pdf');
|
||||
|
||||
@@ -628,8 +626,7 @@ router.post('/online-pdf', authenticate, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
async function JoinPDFCatalogs(cataloghi, options, outputFile, stampa) {
|
||||
async function JoinPDFCatalogs(raccolta, cataloghi, options, outputFile, stampa) {
|
||||
try {
|
||||
// Per ogni catalogo prendi il suo PDF Generato
|
||||
|
||||
@@ -637,6 +634,33 @@ async function JoinPDFCatalogs(cataloghi, options, outputFile, stampa) {
|
||||
|
||||
let numcat = 0;
|
||||
|
||||
// Aggiungi eventuale PDF di copertina
|
||||
|
||||
if (raccolta.pdf_copertina) {
|
||||
let dirmain = '';
|
||||
if (!tools.sulServer()) {
|
||||
dirmain = server_constants.DIR_PUBLIC_LOCALE;
|
||||
}
|
||||
|
||||
const myfile = tools.fixFilePath(
|
||||
path.join(options.mydir + dirmain + '/' + options.dir_out, raccolta.pdf_copertina?.imagefile)
|
||||
);
|
||||
console.log(' copertina: ' + myfile);
|
||||
if (await tools.isFileExistsAsync(myfile)) {
|
||||
const pdfBytes = await fs.promises.readFile(myfile);
|
||||
const pdf = await PDFDocument.load(pdfBytes);
|
||||
const pages = pdf.getPages();
|
||||
const copiedPages = await pdfDoc.copyPages(
|
||||
pdf,
|
||||
pages.map((p, i) => i)
|
||||
);
|
||||
for (let page of copiedPages) {
|
||||
pdfDoc.addPage(page);
|
||||
}
|
||||
console.log(' Aggiungo la copertina ' + myfile);
|
||||
}
|
||||
}
|
||||
|
||||
for (let id_catalog of cataloghi) {
|
||||
let catalog = await Catalog.findOne({ _id: id_catalog });
|
||||
if (catalog) {
|
||||
@@ -647,7 +671,7 @@ async function JoinPDFCatalogs(cataloghi, options, outputFile, stampa) {
|
||||
const filenameOnly = path.parse(myfile).base;
|
||||
|
||||
numcat++;
|
||||
console.log(' Aggiungo il catalogo [' + numcat + '] ' + filenameOnly + ' ...');
|
||||
console.log(' Aggiungo il catalogo [' + numcat + '] ' + filenameOnly + ' ...');
|
||||
|
||||
const pdfBytes = await fs.promises.readFile(myfile);
|
||||
const pdf = await PDFDocument.load(pdfBytes);
|
||||
@@ -701,7 +725,6 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
options.mydir = tools.getdirByIdApp(idapp);
|
||||
|
||||
try {
|
||||
|
||||
const mydirpath = tools.getdirByIdApp(options.idapp);
|
||||
const full_dir_out = tools.fixFilePath(path.join(mydirpath, options.dir_out));
|
||||
await fs.promises.mkdir(full_dir_out, { recursive: true });
|
||||
@@ -709,7 +732,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
// Aggiorna il PDF OnLine, copiando il file da Generato a OnLine
|
||||
let raccolta = await RaccoltaCataloghi.findOne({ _id: options.id_raccolta });
|
||||
|
||||
if (raccolta) {
|
||||
if (raccolta && raccolta.nomefile_da_generare) {
|
||||
cataloghi = raccolta.lista_cataloghi;
|
||||
|
||||
let outputFile = path.join(
|
||||
@@ -721,7 +744,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
outputFileStampa =
|
||||
path.join(full_dir_out, path.basename(tools.removeFileExtension(outputFile))) + '_stampabile.pdf';
|
||||
// Creazione file per STAMPA
|
||||
const ris_stampa = await JoinPDFCatalogs(cataloghi, options, outputFileStampa, true);
|
||||
const ris_stampa = await JoinPDFCatalogs(raccolta, cataloghi, options, outputFileStampa, true);
|
||||
if (ris_stampa) {
|
||||
raccolta.pdf_generato_stampa = ris_stampa.outputPath;
|
||||
let myfilecheckstampa = path.join(mydirpath, ris_stampa.outputPath);
|
||||
@@ -730,7 +753,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
}
|
||||
} else {
|
||||
// Creazione file per WEB
|
||||
const ris = await JoinPDFCatalogs(cataloghi, options, outputFile, false);
|
||||
const ris = await JoinPDFCatalogs(raccolta, cataloghi, options, outputFile, false);
|
||||
if (ris) {
|
||||
raccolta.pdf_generato = ris.outputPath;
|
||||
let myfilecheck = path.join(mydirpath, ris.outputPath);
|
||||
@@ -765,7 +788,7 @@ router.post('/join-pdf', authenticate, async (req, res) => {
|
||||
// risout
|
||||
|
||||
return res.status(200).send(risout);
|
||||
} catch (e) {5
|
||||
} catch (e) {
|
||||
console.error('Err join-pdf', e.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.2.65
|
||||
1.2.66
|
||||
Reference in New Issue
Block a user