module Booklet

Constants

VERSION

Public Instance Methods

pages(pdf) click to toggle source
# File lib/booklet.rb, line 10
def pages(pdf)
  `pdftk #{pdf} dump_data`.split("\n").select { |l| l.start_with? "NumberOfPages:" }[0].split[1].to_i
end
quire_all(p) click to toggle source
# File lib/booklet.rb, line 23
def quire_all(p)
  (1..p).to_a.map { |i|
    case  i % 4
    when 1 then p - (i-1)/2
    when 2 then i/2
    when 3 then (i+1)/2
    else p - i/2 + 1
    end
  }.join(" ")
end
quire_each(p) click to toggle source
# File lib/booklet.rb, line 14
def quire_each(p)
  (1..p).to_a.map { |i|
    case i % 4
    when 1 then i + 3
    else i - 1
    end
  }.join(" ")
end
run(cmd) click to toggle source
# File lib/booklet.rb, line 5
def run(cmd)
  puts "> #{cmd}"
  `#{cmd}`
end