Merge PDF files into a single PDF document
npm install pdf-mergeMerge multiple PDF Files into a single PDF document supporting three output formats: Buffer, Stream, New file on disk.
npm i pdf-merge@0.1.1 should still work.#### Debian, Ubuntu
```
apt-get install pdftk
#### RPM
https://www.pdflabs.com/docs/install-pdftk-on-redhat-or-centos/
, options)files is expected to be an array of files (must be full path for each respective file) or objects.
The file object have the follow options:
* file Full path of PDF fileinputPw
Password to decrypt a PDF Optional!*
options:libPath
Should only be provided if pdftk is not in your PATH Optional!*output
Defaults to Buffer. Values Buffer, Stream, and path to a new file are accepted. Optional!*execOptions
* This is an optional string where you can pass additional argument to pdftk, for
example compress. For the complete list see the docu of the pdftk
javascript
const PDFMerge = require('pdf-merge');const files = [
${__dirname}/1.pdf,
${__dirname}/2.pdf,
{file: ${__dirname}/protected.pdf, inputPw: '_SeCrEt_'}
];//Buffer (Default)
PDFMerge(files)
.then((buffer) => {...});
//Stream
PDFMerge(files, {output: 'Stream'})
.then((stream) => {...});
//Save as new file
PDFMerge(files, {output:
${__dirname}/3.pdf})
.then((buffer) => {...});
``