def decrypt
      raise_encrypted_error @encryption_dictionary unless @encryption_dictionary[:Filter] == :Standard
      @key = set_general_key
      case actual_object(@encryption_dictionary[:V])
      when 1, 2
        # raise_encrypted_error
        _perform_decrypt_proc_ @objects, method(:decrypt_RC4)
      when 4
        # make sure CF is a Hash (as required by the PDF standard for this type of encryption).
        raise_encrypted_error unless actual_object(@encryption_dictionary[:CF]).is_a?(Hash)

        # support trivial case for now
        # - same filter for streams (Stmf) and strings(Strf)
        # - AND :CFM == :V2 (use algorithm 1)
        raise_encrypted_error unless (@encryption_dictionary[:StmF] == @encryption_dictionary[:StrF])

        cfilter = actual_object(@encryption_dictionary[:CF])[@encryption_dictionary[:StrF]]
        raise_encrypted_error unless cfilter
        raise_encrypted_error unless (cfilter[:AuthEvent] == :DocOpen)
        if (cfilter[:CFM] == :V2)
          _perform_decrypt_proc_ @objects, method(:decrypt_RC4)
        elsif (cfilter[:CFM] == :AESV2)
          _perform_decrypt_proc_ @objects, method(:decrypt_AES)
        else
          raise_encrypted_error
        end
      end
      # rebuild stream lengths?
      @objects
    rescue => e
      puts e
      puts e.message
      puts e.backtrace.join("\n")
      raise_encrypted_error
    end
def decrypt
      raise_encrypted_error @encryption_dictionary unless @encryption_dictionary[:Filter] == :Standard
      @key = set_general_key
      case actual_object(@encryption_dictionary[:V])
      when 1, 2
        # raise_encrypted_error
        _perform_decrypt_proc_ @objects, method(:decrypt_RC4)
      when 4
        # make sure CF is a Hash (as required by the PDF standard for this type of encryption).
        raise_encrypted_error unless actual_object(@encryption_dictionary[:CF]).is_a?(Hash)

        # support trivial case for now
        # - same filter for streams (Stmf) and strings(Strf)
        # - AND :CFM == :V2 (use algorithm 1)
        raise_encrypted_error unless (@encryption_dictionary[:StmF] == @encryption_dictionary[:StrF])

        cfilter = actual_object(@encryption_dictionary[:CF])[@encryption_dictionary[:StrF]]
        raise_encrypted_error unless cfilter
        raise_encrypted_error unless (cfilter[:AuthEvent] == :DocOpen)
        if (cfilter[:CFM] == :V2)
          _perform_decrypt_proc_ @objects, method(:decrypt_RC4)
        elsif (cfilter[:CFM] == :AESV2)
          _perform_decrypt_proc_ @objects, method(:decrypt_AES)
        else
          raise_encrypted_error
        end
      end
      # rebuild stream lengths?
      @objects
    rescue => e
      puts e
      puts e.message
      puts e.backtrace.join("\n")
      raise_encrypted_error
    end
include CombinePDF::Renderer
 @!visibility private
 make a new Decrypt object. requires:
 objects:: an array containing the encrypted objects.
 root_dictionary:: the root PDF dictionary, containing the Encrypt dictionary.
 call this to start the decryption.