nbesli/pdf-merger-js

feat proposal: addAllFromFolder

Closed this issue · 2 comments

It would be convenient to add all files on a folder, like:

  // const folder = "./test-folder/"
  addAllFromFolder(folder) {
    fs.readdirSync(folder).forEach((file) => {
      this._addEntireDocument(`${folder}${file}`)
    })
  }

for now you could do something like this (untested):

const glob = require('glob');

glob(FOLDER + '/*.pdf', {}, 
  (err, files) => 
    files.forEach(file => 
      merger.add(file)
    )
);

This conflicts with browser support (#17). Because there is a easy workaround I think we can close this.