Class: PDF::Core::ObjectStore Private
- Inherits:
-
Object
- Object
- PDF::Core::ObjectStore
- Includes:
- Enumerable
- Defined in:
- lib/pdf/core/object_store.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
PDF object repository
Instance Attribute Summary collapse
-
#min_version ⇒ Float
readonly
private
Minimum PDF version.
Instance Method Summary collapse
-
#[](id) ⇒ Reference
private
Get object reference by its identifier.
-
#each {|ref| ... } ⇒ void
private
Iterate over document object references.
-
#info ⇒ Reference
private
Document info dict reference.
-
#initialize(opts = {}) ⇒ ObjectStore
constructor
private
A new instance of ObjectStore.
-
#object_id_for_page(page) ⇒ Integer
private
Get page reference identifier by page number.Pages are indexed starting at 1 (**not 0**).
-
#page_count ⇒ Integer
private
Number of pages in the document.
-
#pages ⇒ Reference
private
Document pages reference.
-
#push(*args) ⇒ Object
(also: #<<)
private
Adds the given reference to the store and returns the reference object.
-
#ref(data) ⇒ Reference
private
Wrap an object into a reference.
-
#root ⇒ Reference
private
Document root dict reference.
-
#size ⇒ Integer
(also: #length)
private
Number of object references in the document.
Constructor Details
#initialize(opts = {}) ⇒ ObjectStore
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ObjectStore.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pdf/core/object_store.rb', line 19 def initialize(opts = {}) @objects = {} @identifiers = [] @info ||= ref(opts[:info] || {}).identifier @root ||= ref(Type: :Catalog).identifier if opts[:print_scaling] == :none root.data[:ViewerPreferences] = { PrintScaling: :None } end if pages.nil? root.data[:Pages] = ref(Type: :Pages, Count: 0, Kids: []) end end |
Instance Attribute Details
#min_version ⇒ Float (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Minimum PDF version
13 14 15 |
# File 'lib/pdf/core/object_store.rb', line 13 def min_version @min_version end |
Instance Method Details
#[](id) ⇒ Reference
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get object reference by its identifier.
111 112 113 |
# File 'lib/pdf/core/object_store.rb', line 111 def [](id) @objects[id] end |
#each {|ref| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Iterate over document object references.
101 102 103 104 105 |
# File 'lib/pdf/core/object_store.rb', line 101 def each @identifiers.each do |id| yield(@objects[id]) end end |
#info ⇒ Reference
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Document info dict reference
45 46 47 |
# File 'lib/pdf/core/object_store.rb', line 45 def info @objects[@info] end |
#object_id_for_page(page) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get page reference identifier by page number.Pages are indexed starting at 1 (**not 0**).
137 138 139 140 141 |
# File 'lib/pdf/core/object_store.rb', line 137 def object_id_for_page(page) page -= 1 if page.positive? flat_page_ids = get_page_objects(pages).flatten flat_page_ids[page] end |
#page_count ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Number of pages in the document
66 67 68 |
# File 'lib/pdf/core/object_store.rb', line 66 def page_count pages.data[:Count] end |
#pages ⇒ Reference
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Document pages reference
59 60 61 |
# File 'lib/pdf/core/object_store.rb', line 59 def pages root.data[:Pages] end |
#push(reference) ⇒ reference #push(id, data) ⇒ Reference Also known as: <<
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds the given reference to the store and returns the reference object. If the object provided is not a PDF::Core::Reference, one is created from the arguments provided.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pdf/core/object_store.rb', line 82 def push(*args) reference = if args.first.is_a?(PDF::Core::Reference) args.first else PDF::Core::Reference.new(*args) end @objects[reference.identifier] = reference @identifiers << reference.identifier reference end |
#ref(data) ⇒ Reference
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wrap an object into a reference.
38 39 40 |
# File 'lib/pdf/core/object_store.rb', line 38 def ref(data) push(size + 1, data) end |
#root ⇒ Reference
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Document root dict reference
52 53 54 |
# File 'lib/pdf/core/object_store.rb', line 52 def root @objects[@root] end |
#size ⇒ Integer Also known as: length
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Number of object references in the document.
118 119 120 |
# File 'lib/pdf/core/object_store.rb', line 118 def size @identifiers.size end |