Permalink
Browse files

just do what i ask

  • Loading branch information...
1 parent 895408f commit 2a355e877b25d8fb855dfb521b7abedf6a1d4781 @darkhelmet darkhelmet committed Dec 20, 2011
Showing with 6 additions and 18 deletions.
  1. +3 −15 lib/active_pdftk/call.rb
  2. +3 −3 lib/active_pdftk/wrapper.rb
View
18 lib/active_pdftk/call.rb
@@ -327,13 +327,8 @@ def locate_pdftk
def build_input(args)
out, i = [[], "input_pw",[]], "A"
case args
- when Hash
@elmatou
elmatou added a line comment Dec 20, 2011

This is really needed for multiple files handling, operation cat, shuffle, ...
... A=first.pdf B=second.pdf cat B3 A4-end...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- @input_file_map = {}
- args.each do |file, pass|
- out.first << "#{i.next!}=#{file}"
- out.last << "#{i}=#{pass}" if pass
- @input_file_map[file] = "#{i}"
- end
+ when Array
+ out[0] = args
when String
out.first << args
when File, Tempfile, StringIO
@@ -364,14 +359,7 @@ def build_operation(*args)
check_statement(abilities, operation.first)
@operation_name = operation.first
if [:cat, :shuffle].include?(operation.first)
- if operation.last.nil? || operation.last.empty? || !operation.last.is_a?(Array)
- raise(InvalidOptions, {:cmd => operation.first})
- elsif operation.last.collect{|h| h[:pdf]}.uniq.size > 1 && (@input_file_map.nil? || @input_file_map.empty?)
- raise MissingInput
- else
- ops = operation.last.collect {|range| build_range_option(range)}
- [operation.first.to_s] + ops
- end
+ %w(cat)
else
case operation.last
when NilClass
View
6 lib/active_pdftk/wrapper.rb
@@ -68,8 +68,8 @@ def generate_fdf(template, options = {})
# @example
# cat([{:pdf => 'a.pdf', :pass => 'foo'}, {:pdf => 'b.pdf', :start => 1, :end => 'end', :orientation => 'N', :pages => 'even'}]) # will return +StringIO+ of a single PDF containing a.pdf and the even pages of b.pdf
# cat([{:pdf => 'a.pdf', :pass => 'foo'}, {:pdf => 'b.pdf', :start => 1, :end => 'end', :orientation => 'N', :pages => 'even'}], :output => 'c.pdf') # will write the same as above to c.pdf
- def cat(ranges = [], options = {})
- command_options = call_range_operation(:cat, ranges)
+ def cat(files = [], options = {})
+ command_options = { :input => files, :operation => { :cat => [] } }
@call.pdftk(options.merge(command_options))
end
@@ -122,7 +122,7 @@ def background(template, background, options = {})
command_options = call_multi_operation("background", template, background, options.delete(:multi))
@call.pdftk(options.merge(command_options))
end
-
+
# Similar to #background, however if the background file it is multiple pages it will apply each page of the background file to the corresponding page of the template.
# If the template has more pages than the background file the last page of the background file will be repeated.
# @param [String, File, Tempfile, StringIO] template is the file on which the form is based.

0 comments on commit 2a355e8

Please sign in to comment.