lib/hexapdf/document.rb in hexapdf-0.11.9 vs lib/hexapdf/document.rb in hexapdf-0.12.0
- old
+ new
@@ -2,11 +2,11 @@
#
#--
# This file is part of HexaPDF.
#
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
-# Copyright (C) 2014-2019 Thomas Leitner
+# Copyright (C) 2014-2020 Thomas Leitner
#
# HexaPDF is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3 as
# published by the Free Software Foundation with the addition of the
# following permission added to Section 15 as permitted in Section 7(a):
@@ -53,10 +53,11 @@
require 'hexapdf/layout'
begin
require 'hexapdf/cext'
rescue LoadError
+ # ignore error because the C-extension only makes things faster
end
# == HexaPDF API Documentation
#
# Here are some pointers to more in depth information:
@@ -130,13 +131,14 @@
# io:: If an IO object is provided, then this document can read PDF objects from this IO
# object, otherwise it can only contain created PDF objects.
#
# decryption_opts:: A hash with options for decrypting the PDF objects loaded from the IO.
#
- # config:: A hash with configuration options that is deep-merged into the default
- # configuration (see DefaultDocumentConfiguration), meaning that direct sub-hashes
- # are merged instead of overwritten.
+ # config:: A hash with configuration options that is deep-merged into the default configuration
+ # (see
+ # HexaPDF::DefaultDocumentConfiguration[../index.html#DefaultDocumentConfiguration],
+ # meaning that direct sub-hashes are merged instead of overwritten.
def initialize(io: nil, decryption_opts: {}, config: {})
@config = Configuration.with_defaults(config)
@version = '1.2'
@revisions = Revisions.from_io(self, io)
@@ -375,11 +377,11 @@
end
case object
when Hash
seen[object] = true
- object.each_with_object({}) {|(key, val), memo| memo[key] = unwrap(val, seen.dup) }
+ object.transform_values {|value| unwrap(value, seen.dup) }
when Array
seen[object] = true
object.map {|inner_o| unwrap(inner_o, seen.dup) }
when HexaPDF::PDFData
seen[object] = true
@@ -492,9 +494,16 @@
end
# Returns the Fonts object that provides convenience methods for working with fonts.
def fonts
@fonts ||= Fonts.new(self)
+ end
+
+ # Returns the main AcroForm object for dealing with interactive forms.
+ #
+ # See HexaPDF::Type::Catalog#acro_form for details on the arguments.
+ def acro_form(create: false)
+ catalog.acro_form(create: create)
end
# Executes the given task and returns its result.
#
# Tasks provide an extensible way for performing operations on a PDF document without