lib/hexapdf/document.rb in hexapdf-0.10.0 vs lib/hexapdf/document.rb in hexapdf-0.11.0
- old
+ new
@@ -38,10 +38,11 @@
require 'hexapdf/error'
require 'hexapdf/content'
require 'hexapdf/configuration'
require 'hexapdf/reference'
require 'hexapdf/object'
+require 'hexapdf/pdf_array'
require 'hexapdf/stream'
require 'hexapdf/revisions'
require 'hexapdf/type'
require 'hexapdf/task'
require 'hexapdf/encryption'
@@ -133,11 +134,11 @@
@config = Configuration.with_defaults(config)
@version = '1.2'
@revisions = Revisions.from_io(self, io)
@security_handler = if encrypted? && @config['document.auto_decrypt']
- Encryption::SecurityHandler.set_up_decryption(self, decryption_opts)
+ Encryption::SecurityHandler.set_up_decryption(self, **decryption_opts)
else
nil
end
@listeners = {}
@@ -197,11 +198,11 @@
# additional keyword arguments.
#
# If the +revision+ option is +:current+, the current revision is used. Otherwise +revision+
# should be a revision index.
def add(obj, revision: :current, **wrap_opts)
- obj = wrap(obj, wrap_opts) unless obj.kind_of?(HexaPDF::Object)
+ obj = wrap(obj, **wrap_opts) unless obj.kind_of?(HexaPDF::Object)
revision = (revision == :current ? @revisions.current : @revisions.revision(revision))
if revision.nil?
raise ArgumentError, "Invalid revision index specified"
end
@@ -292,11 +293,12 @@
# Additionally, if there is no +type+ but a +subtype+, all required fields of the subtype
# class need to have values; otherwise the subtype class is not used. This is done to better
# prevent invalid mappings when only partial knowledge (:Type key is missing) is available.
#
# * If there is no valid class after the above steps, HexaPDF::Stream is used if a stream is
- # given, HexaPDF::Dictionary if the given objecct is a hash or else HexaPDF::Object is used.
+ # given, HexaPDF::Dictionary if the given object is a hash, HexaPDF::PDFArray if it is an
+ # array or else HexaPDF::Object is used.
#
# Options:
#
# :type:: (Symbol or Class) The type of a PDF object that should be used for wrapping. This
# could be, for example, :Pages. If a class object is provided, it is used directly
@@ -344,9 +346,11 @@
klass ||= if data.stream
HexaPDF::Stream
elsif data.value.kind_of?(Hash)
HexaPDF::Dictionary
+ elsif data.value.kind_of?(Array)
+ HexaPDF::PDFArray
else
HexaPDF::Object
end
klass.new(data, document: self)