class Libis::Format::Converter::PdfWatermarkerText
Public Class Methods
input_types()
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.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_text.rb, line 26 def initialize super @text = [] @options[:opacity] = '0.3' end
output_types(format = nil)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.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_text.rb, line 56 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_text.rb, line 67 def convert_pdf(source, target) using_temp(target) do |tmpname| result = Libis::Format::Tool::PdfWatermark.run( source, tmpname, 'text', @options.map {|k, v| if v.nil? nil else ["--#{k}", v.to_s] end }.compact.flatten + @text ) unless result[:err].empty? error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n"))) next nil end tmpname end end
gap(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 48 def gap(v) @options[:gap] = v end
opacity(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 44 def opacity(v) @options[:opacity] = v unless v.blank? end
padding(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 52 def padding(v) @options[:padding] = v end
pdf_watermark_text(_)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 22 def pdf_watermark_text(_) #force usage of this converter end
rotation(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 36 def rotation(v) @options[:rotation] = v unless v.blank? end
size(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 40 def size(v) @options[:size] = v unless v.blank? end
text(v)
click to toggle source
# File lib/libis/format/converter/pdf_watermarker_text.rb, line 32 def text(v) @text += v.split("\n") end