Skip to content

Instantly share code, notes, and snippets.

@kch
Created January 13, 2013 21:06
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 kch/4526218 to your computer and use it in GitHub Desktop.
Save kch/4526218 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: UTF-8
# merge pages from two pdf documents (same as Merge Every Other)
# only the two documents to be merged must be opened, the first must be the front window.
# this assumes a feed scanner, hence expects the second document's pages to be reversed.
require 'appscript'
include Appscript
pp=app('pdfpen')
a, b, c = *pp.documents.get, pp.make(:new => :document)
a.pages.get.zip(b.pages.get.reverse).flatten.each { |p| pp.duplicate p, to:c.pages.end }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment