nbesli/pdf-merger-js

Support for pdf/a pdf formats in merging pdfs

jaslam-ca opened this issue · 2 comments

The library's(new PDFMerger()).add() function throws error "Expected instance of PDFDict, but got instance of undefined" when used with pdf/a files.

Following doesn't work with a pdf/a format:
pdf-a.pdf

npx pdf-merger-cli out.pdf pdf-a.pdf pdf-a.pdf

pdf-a error

Following does work without a pdf/a format:
pdf-woa.pdf

npx pdf-merger-cli out.pdf pdf-woa.pdf pdf-woa.pdf

I met the same issue when using merger.add() to merge some of the files. @jaslam-ca @mojoaxel any idea for this?

  • My code:
const render = async () => {
  const merger = new PDFMerger();

  for (const file of files) {
    console.log("sonnn", file);
    await merger.add(file.file).catch(e => {
      console.log("sonnn", e);
    });
  }

  const mergedPdf = await merger.saveAsBlob();
  const url = URL.createObjectURL(mergedPdf);

  return setPdf(url);
};
  • My error log:

image