Class: PDFRavager::Strategies::Smart

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_ravager/strategies/smart.rb

Instance Method Summary collapse

Constructor Details

#initialize(stamper) ⇒ Smart

Returns a new instance of Smart.



4
5
6
7
# File 'lib/pdf_ravager/strategies/smart.rb', line 4

def initialize(stamper)
  @acro_form = Strategies::AcroForm.new(stamper)
  @xfa       = Strategies::XFA.new(stamper)
end

Instance Method Details

#set_field_values(template) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/pdf_ravager/strategies/smart.rb', line 9

def set_field_values(template)
  parsed_fields = @acro_form.set_field_values(template)
  unparsed_fields = template.fields - parsed_fields
  if unparsed_fields.any?
    @xfa.set_field_values(Template.new{|t| t.fields = unparsed_fields })
  end
end

#set_read_onlyObject



17
18
19
# File 'lib/pdf_ravager/strategies/smart.rb', line 17

def set_read_only
  [@acro_form, @xfa].each(&:set_read_only)
end