Sha256: 6614760781852abdda28b02c03bea5f01bf4318217aaa24f82c53a7fccc25fc9
Contents?: true
Size: 845 Bytes
Versions: 4
Compression:
Stored size: 845 Bytes
Contents
module Docsplit # Delegates to **pdftk** in order to create bursted single pages from # a PDF document. class PageExtractor # Burst a list of pdfs into single pages, as `pdfname_pagenumber.pdf`. def extract(pdfs, opts) 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" result = `#{cmd}`.chomp FileUtils.rm('doc_data.txt') if File.exists?('doc_data.txt') raise ExtractionFailed, result if $? != 0 result end end private def extract_options(options) @output = options[:output] || '.' end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
docsplit-0.6.3 | lib/docsplit/page_extractor.rb |
docsplit-0.6.2 | lib/docsplit/page_extractor.rb |
docsplit-0.6.1 | lib/docsplit/page_extractor.rb |
docsplit-0.6.0 | lib/docsplit/page_extractor.rb |