class Libis::Format::Converter::PdfSplitter
noinspection DuplicatedCode
Public Class Methods
category()
click to toggle source
# File lib/libis/format/converter/pdf_splitter.rb, line 23 def self.category :splitter end
input_types()
click to toggle source
# File lib/libis/format/converter/pdf_splitter.rb, line 14 def self.input_types [:PDF] end
new()
click to toggle source
Calls superclass method
Libis::Format::Converter::Base::new
# File lib/libis/format/converter/pdf_splitter.rb, line 27 def initialize super end
output_types(format = nil)
click to toggle source
# File lib/libis/format/converter/pdf_splitter.rb, line 18 def self.output_types(format = nil) return [] unless input_types.include?(format) if format [:PDFA] end
Public Instance Methods
convert(source, target, format, opts = {})
click to toggle source
Calls superclass method
Libis::Format::Converter::Base#convert
# File lib/libis/format/converter/pdf_splitter.rb, line 36 def convert(source, target, format, opts = {}) super result = split(source, target) return nil unless result result end
page(v)
click to toggle source
Split at given page. If omitted, nil or 0, the source PDF will be split at every page
# File lib/libis/format/converter/pdf_splitter.rb, line 32 def page(v) @options[:page] = v unless v.blank? end
Private Instance Methods
split(source, target)
click to toggle source
# File lib/libis/format/converter/pdf_splitter.rb, line 47 def split(source, target) result = Libis::Format::Tool::PdfSplit.run( source, target, @options.map { |k, v| if v.nil? nil else ["--#{k}", v.to_s] end }.compact.flatten ) unless result[:err].empty? error("Pdf split encountered errors:\n%s", result[:err].join(join("\n"))) return nil end result[:out] end