Class | PDF::Reader::ObjectHash |
In: |
lib/pdf/reader/object_hash.rb
|
Parent: | Object |
Provides low level access to the objects in a PDF file via a hash-like object.
A PDF file can be viewed as a large hash map. It is a series of objects stored at precise byte offsets, and a table that maps object IDs to byte offsets. Given an object ID, looking up an object is an O(1) operation.
Each PDF object can be mapped to a ruby object, so by passing an object ID to the [] method, a ruby representation of that object will be retrieved.
The class behaves much like a standard Ruby hash, including the use of the Enumerable mixin. The key difference is no []= method - the hash is read only.
h = PDF::Reader::ObjectHash.new("somefile.pdf") h[1] => 3469 h[PDF::Reader::Reference.new(1,0)] => 3469
default | [RW] | |
pdf_version | [R] | |
sec_handler | [R] | |
trailer | [R] |
Creates a new ObjectHash object. Input can be a string with a valid filename or an IO-like object.
Valid options:
:password - the user password to decrypt the source PDF
Access an object from the PDF. key can be an int or a PDF::Reader::Reference object.
If an int is used, the object with that ID and a generation number of 0 will be returned.
If a PDF::Reader::Reference object is used the exact ID and generation number can be specified.
Recursively dereferences the object refered to be key. If key is not a PDF::Reader::Reference, the key is returned unchanged.
Access an object from the PDF. key can be an int or a PDF::Reader::Reference object.
If an int is used, the object with that ID and a generation number of 0 will be returned.
If a PDF::Reader::Reference object is used the exact ID and generation number can be specified.
local_default is the object that will be returned if the requested key doesn‘t exist.
return true if the specified key exists in the file. key can be an int or a PDF::Reader::Reference
If key is a PDF::Reader::Reference object, lookup the corresponding object in the PDF and return it. Otherwise return key untouched.
return the number of objects in the file. An object with multiple generations is counted once.