class Libis::Format::Converter::PdfWatermarkerHeader

Public Class Methods

input_types() click to toggle source
# File lib/libis/format/converter/pdf_watermarker_header.rb, line 13
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_watermarker_header.rb, line 26
def initialize
  super
end
output_types(format = nil) click to toggle source
# File lib/libis/format/converter/pdf_watermarker_header.rb, line 17
def self.output_types(format = nil)
  return [] unless input_types.include?(format) if format
  [:PDF]
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_watermarker_header.rb, line 34
def convert(source, target, format, opts = {})
  super

  result = convert_pdf(source, target)
  return nil unless result

  result

end
convert_pdf(source, target) click to toggle source

noinspection DuplicatedCode

# File lib/libis/format/converter/pdf_watermarker_header.rb, line 45
def convert_pdf(source, target)

  using_temp(target) do |tmpname|
    result = Libis::Format::Tool::PdfWatermark.run(
        source, tmpname, 'header',
        @options.map {|k, v|
          if v.nil?
            nil
          else
            ["--#{k}", v.to_s]
          end
          }.compact.flatten
    )
    unless result[:err].empty?
      error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
      next nil
    end
    tmpname
  end

end
pdf_watermark_header(_) click to toggle source
# File lib/libis/format/converter/pdf_watermarker_header.rb, line 22
def pdf_watermark_header(_)
  #force usage of this converter
end
text(v) click to toggle source
# File lib/libis/format/converter/pdf_watermarker_header.rb, line 30
def text(v)
  @options[:text] = v.blank? ? nil : v
end