I use the fill-pdf npm module to populate the pdf template and it creates a new file that is read from disk and returned as a buffer for the callback. I have two files for which I perform the same operation. I want to combine the two buffers there to form a single PDF file that I can send back to the client. I have tried various buffer concatenation methods. A buffer can be combined using Buffer.concat, for example,
var newBuffer = Buffer.concat([result_pdf.output, result_pdf_new.output]);
The size of the new buffer is also the sum of the size of the input buffers. But still, when newBuffer sent to the client as an answer, it only shows the file specified by the last in the array.
res.type("application/pdf"); return res.send(buffer);
Any idea?
source share