merger.save() actually merge old merged pdf with new merged pdf,
AbhayKrSing opened this issue · 2 comments
AbhayKrSing commented
const PDFMerger = require('pdf-merger-js');
const merger = new PDFMerger();
const multer = require('multer')
const upload = multer({ dest: 'uploads/' })
app.post('/merge', upload.array('files', 12), async (req, res) => {
try {
const files_array = req.files //file coming from front end side (using react)
console.log(files_array)
for (value of files_array) {
await merger.add(`./uploads/${value.filename}`);
}
await merger.save('./Merged-files/merged.pdf') //It merge old merged pdf with new merged pdf if above api call in short interval.
res.status(200).send({ success: 'Done successfully merged' })
for (value of files_array) {
fs.unlinkSync(`./uploads/${value.filename}`)
}
} catch (error) {
console.log(error.message)
}
})
kushalking commented
Same issue with me