mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-27 00:07:01 +01:00
15 lines
460 B
JavaScript
15 lines
460 B
JavaScript
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();
|
|
}; |