I have an array of Unit8Array elements, where each Unit8Array represents an encoded PDF, then I do:
const files = encodedPdfUnit8Array.map(pdf => {
const blob = new Blob([pdf, {type: 'application/pdf'});
return new File([blob], "", {lastModified: new Date().getTime(), type: blob.type});
});
// and then I do
const mergePDFHandler = async (files) => {
// note the missing async after the forEach loop which is not in the docs.
files.forEach(async (file)=>await createPDF.PDFDocumentFromFile(file))
const mergedPDFDocument = await mergePDF(files)
const mergedPdfFile = await mergedPDFDocument.save();
const pdfBlob = pdfArrayToBlob(mergedPdfFile);
};
mergePDF.js:10 Uncaught (in promise) TypeError: fileDoc.getPageIndices is not a function
at mergePDF (<anonymous>:37507:62)