lib/hexapdf/cli/command.rb in hexapdf-0.12.3 vs lib/hexapdf/cli/command.rb in hexapdf-0.13.0

- old
+ new

@@ -98,10 +98,11 @@ # Returns a hash with HexaPDF::Document options based on the given password and the option # switches. def pdf_options(password) hash = {decryption_opts: {password: password}, config: {}} HexaPDF::GlobalConfiguration['filter.predictor.strict'] = command_parser.strict + hash[:config]['parser.try_xref_reconstruction'] = !command_parser.strict hash[:config]['parser.on_correctable_error'] = if command_parser.strict proc { true } else proc do |_, msg, pos| @@ -275,17 +276,18 @@ # Applies the encryption related options to the given HexaPDF::Document instance. # # See: #define_encryption_options def apply_encryption_options(doc) - if @out_options.encryption == :add + case @out_options.encryption + when :add doc.encrypt(algorithm: @out_options.enc_algorithm, key_length: @out_options.enc_key_length, force_v4: @out_options.enc_force_v4, permissions: @out_options.enc_permissions, owner_password: @out_options.enc_owner_pwd, user_password: @out_options.enc_user_pwd) - elsif @out_options.encryption == :remove + when :remove doc.encrypt(name: nil) end end PAGE_NUMBER_SPEC = "(r?[1-9]\\d*|e)" #:nodoc: