lib/docsplit/page_extractor.rb in docsplit-0.6.3 vs lib/docsplit/page_extractor.rb in docsplit-0.6.4

- old
+ new

@@ -9,10 +9,15 @@ extract_options opts [pdfs].flatten.each do |pdf| pdf_name = File.basename(pdf, File.extname(pdf)) page_path = File.join(@output, "#{pdf_name}_%d.pdf") FileUtils.mkdir_p @output unless File.exists?(@output) - cmd = "pdftk #{ESCAPE[pdf]} burst output #{ESCAPE[page_path]} 2>&1" + + cmd = if DEPENDENCIES[:pdftailor] # prefer pdftailor, but keep pdftk for backwards compatability + "pdftailor unstitch --output #{ESCAPE[page_path]} #{ESCAPE[pdf]} 2>&1" + else + "pdftk #{ESCAPE[pdf]} burst output #{ESCAPE[page_path]} 2>&1" + end result = `#{cmd}`.chomp FileUtils.rm('doc_data.txt') if File.exists?('doc_data.txt') raise ExtractionFailed, result if $? != 0 result end \ No newline at end of file