Fixed downloading buffer, merging workflow

This commit is contained in:
Felix Kaspar
2023-10-17 02:14:06 +02:00
parent 96bac91fa1
commit 8e8c4596bf
5 changed files with 54 additions and 23 deletions

View File

@@ -0,0 +1,15 @@
const { PDFDocument, ParseSpeeds } = PDFLib;
export const mergePDFs = async (snapshots) => {
const mergedPdf = await PDFDocument.create();
for (let i = 0; i < snapshots.length; i++) {
const pdfToMerge = await PDFDocument.load(snapshots[i]);
const copiedPages = await mergedPdf.copyPages(pdfToMerge, pdfToMerge.getPageIndices());
copiedPages.forEach((page) => mergedPdf.addPage(page));
}
return mergedPdf.save();
};