Created
January 12, 2012 12:40
-
-
Save rriemann/1600271 to your computer and use it in GitHub Desktop.
merge pdf files using ghostscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.first == "--help" | |
puts <<-EOF | |
usage: pdfmerge.rb SUMMARYFILE FILE1 FILE2 ... | |
All Files have to be pdf-Files. Requires GhostScript (gs). | |
Copyright 2009 Robert Riemann - licensed under GPL v2 or higher. | |
EOF | |
exit | |
end | |
begin | |
( ARGV.size - 1 ).times { |i| | |
# raise RuntimeError, ARGV[i+1] + " doesn't exist. Aborting." unless File.exists? ARGV[i+1] | |
raise ARGV[i+1] + " doesn't exist. Aborting." unless File.exists? ARGV[i+1] | |
} | |
rescue | |
STDERR.puts $! | |
exit 1 | |
end | |
files = ARGV.join('" "') | |
%x[gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="#{files}"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment