lib/combine_pdf/parser.rb in combine_pdf-1.0.22 vs lib/combine_pdf/parser.rb in combine_pdf-1.0.23

- old
+ new

@@ -31,11 +31,11 @@ # the info and root objects, as found (if found) in the PDF file. # # they are mainly to used to know if the file is (was) encrypted and to get more details. attr_reader :info_object, :root_object, :names_object, :forms_object, :outlines_object, :metadata - attr_reader :allow_optional_content + attr_reader :allow_optional_content, :raise_on_encrypted # when creating a parser, it is important to set the data (String) we wish to parse. # # <b>the data is required and it is not possible to set the data at a later stage</b> # # string:: the data to be parsed, as a String object. @@ -56,10 +56,11 @@ @strings_dictionary = {}.dup # all strings are one string @resolution_hash = {}.dup @version = nil @scanner = nil @allow_optional_content = options[:allow_optional_content] + @raise_on_encrypted = options[:raise_on_encrypted] end # parse the data in the new parser (the data already set through the initialize / new method) def parse return [] if @string_to_parse.empty? @@ -94,9 +95,10 @@ if @root_object == {}.freeze raise ParsingError, 'root is unknown - cannot determine if file is Encrypted' end if @root_object[:Encrypt] + raise EncryptionError, 'the file is encrypted' if @raise_on_encrypted # change_references_to_actual_values @root_object warn 'PDF is Encrypted! Attempting to decrypt - not yet fully supported.' decryptor = PDFDecrypt.new @parsed, @root_object decryptor.decrypt # do we really need to apply to @parsed? No, there is no need.