class PDFRavager::Strategies::AcroForm

Public Class Methods

new(stamper) click to toggle source
# File lib/pdf_ravager/strategies/acro_form.rb, line 4
def initialize(stamper)
  @stamper = stamper
  @afields = stamper.getAcroFields
end

Public Instance Methods

set_field_values(template) click to toggle source
# File lib/pdf_ravager/strategies/acro_form.rb, line 9
def set_field_values(template)
  template.fields.select{|f| f.respond_to?(:acro_form_value)}.select do |f|
    begin
      # first assume the user has provided the full/raw SOM path
      unless @afields.setField(f.acro_form_name, f.acro_form_value)
        # if that fails, try setting the shorthand version of the path
        @afields.setField(FieldTypes::AcroForm::SOM.short_name(f.acro_form_name), f.acro_form_value)
      end
    rescue java.lang.NullPointerException
      false
    end
  end
end
set_read_only() click to toggle source
# File lib/pdf_ravager/strategies/acro_form.rb, line 23
def set_read_only
  @stamper.setFormFlattening(true)
end