mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-27 00:07:01 +01:00
26cdb1d04f
Frontend traverser needs to be updated
13 lines
436 B
JavaScript
13 lines
436 B
JavaScript
export const mergePDFs = async (snapshots, PDFLib) => {
|
|
|
|
const mergedPdf = await PDFLib.PDFDocument.create();
|
|
|
|
for (let i = 0; i < snapshots.length; i++) {
|
|
const pdfToMerge = await PDFLib.PDFDocument.load(snapshots[i]);
|
|
|
|
const copiedPages = await mergedPdf.copyPages(pdfToMerge, pdfToMerge.getPageIndices());
|
|
copiedPages.forEach((page) => mergedPdf.addPage(page));
|
|
}
|
|
|
|
return mergedPdf.save();
|
|
}; |