Class: PDFRavager::Strategies::Smart
- Inherits:
-
Object
- Object
- PDFRavager::Strategies::Smart
- Defined in:
- lib/pdf_ravager/strategies/smart.rb
Instance Method Summary collapse
-
#initialize(stamper) ⇒ Smart
constructor
A new instance of Smart.
- #set_field_values(template) ⇒ Object
- #set_read_only ⇒ Object
Constructor Details
#initialize(stamper) ⇒ Smart
Returns a new instance of Smart.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pdf_ravager/strategies/smart.rb', line 4 def initialize(stamper) @acro_form = Strategies::AcroForm.new(stamper) @xfa = Strategies::XFA.new(stamper) afields = stamper.getAcroFields @type = if afields.getXfa.isXfaPresent if afields.getFields.empty? :dynamic_xfa else :static_xfa end else :acro_form end end |
Instance Method Details
#set_field_values(template) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/pdf_ravager/strategies/smart.rb', line 19 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_only ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/pdf_ravager/strategies/smart.rb', line 27 def set_read_only case @type when :acro_form, :static_xfa @acro_form.set_read_only when :dynamic_xfa @xfa.set_read_only end end |