wubzz / pdf-merge

Merge multiple PDF Files into a single PDF document

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example

prescottprue opened this issue · comments

It would be really nice to have a working example that can be run. I am not able to get any successful output from the library at all.

Docs aren't super clear on if you are supposed to provide file streams or file paths (found out it was paths by getting an error when trying to pass a readStream).

Tried tons of combinations including:

 new PDFMerge([__dirname + '/test.pdf'])
    .merge(function(err, res){
       console.log('res:', err, res)
    })

then

 new PDFMerge([__dirname + '/test.pdf'])
    .asNewFile(__dirname + '/merged.pdf')
    .merge(function(err, res){
       console.log('res:', err, res)
    })

and another

new PDFMerge([__dirname + '/test.pdf'])
    .asNewFile(__dirname + '/merged.pdf')
    .promise()
    .then(function(res) { console.log('res:', res) })
    .catch(function(err) { console.log('error:', err) })
commented

@prescottprue Added example to docs.

Are you running this on Windows or Linux? Should always get either an error or a success. Either one would be interesting in the context of this issue.

@wubzz Thanks for the example! I am using Mac (i.e. Linux), and was seeing absolutely nothing.

Ill try out the example and go from there, it could be something small I am missing.

I had the same issue on Mac OS Sierra - hanging with no output. Turned out to be a problem with the pdftk server. See this link: http://stackoverflow.com/questions/39750883/pdftk-hanging-on-macos-sierra. Solved the issue for me.