Sha256: 9e0cfe0f6224e1ca38ce1544ebe55e78ce85324b00441813a689534049da836b

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

module PDFRavager
  module Strategies
    class AcroForm
      def initialize(stamper)
        @stamper = stamper
        @afields = stamper.getAcroFields
      end

      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

      def set_read_only
        @stamper.setFormFlattening(true)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdf_ravager-0.2.2 lib/pdf_ravager/strategies/acro_form.rb