I'm trying to combine multiple pdfs to make one file. I have found a script online that does this but I don't want to manually click to upload the files, I simply want to just merge them from their existing location and download.
Here's the example I have: jsfiddle
Here are the PDF placeholders I wish to use:
and
This is the part that is merging the PDFs from what I can tell but how do I point this towards my files as opposed to using the current method?
async function joinPdf() {
const mergedPdf = await PDFDocument.create();
for (let document of window.arrayOfPdf) {
document = await PDFDocument.load(document.bytes);
const copiedPages = await mergedPdf.copyPages(document, document.getPageIndices());
copiedPages.forEach((page) => mergedPdf.addPage(page));
}
var pdfBytes = await mergedPdf.save();
download(pdfBytes, "pdfconbined" + new Date().getTime() + ".pdf", "application/pdf");
}
input.addEventListener('change', openfile, false);
function mostrarDados() {
}