Skip to content

Instantly share code, notes, and snippets.

@radekstepan
Created September 8, 2013 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radekstepan/6484404 to your computer and use it in GitHub Desktop.
Save radekstepan/6484404 to your computer and use it in GitHub Desktop.
merge pdfs together
fs = require 'fs'
path = require 'path'
async = require 'async'
{ exec } = require 'child_process'
outs = []
async.each ( file for file in fs.readdirSync('.') when path.extname(file) is '.pdf' ), (file, cb) ->
outs.push out = path.basename(file, '.pdf') + 'decrypted.pdf'
exec "qpdf #{file} #{out} --decrypt", cb
, (err) ->
outs.sort (a,b) -> parseInt(a) - parseInt(b)
exec "pdfunite #{outs.join(' ')} out.pdf", ->
console.log 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment