Implementation of the PDF dictionary type.
Subclasses should use the available class method ::define_field to create fields according to the PDF specification. This allows, among other things, automatic type checking and basic validation.
Fields defined in superclasses are inherited by their subclasses. This avoids duplicating basic field information.
See: PDF1.7 s7.3.7
Public Class Methods
Defines an entry for the field
name and returns the initalized
object. A suitable converter module (see
HexaPDF::DictionaryFields::Field#converter) is selected based on the type
The class (or an array of classes) that a value of this field must have. Here is a mapping from PDF object types to classes:
[TrueClass, FalseClass] (or use the Boolean constant)
String (for text strings), PDFByteString (for binary strings)
PDFArray or Array
Dictionary (or any subclass) or Hash
Stream (or any subclass)
If an array of classes is provided, the value can be an instance of any of these classes.
If a Symbol object instead of a class is provided, the class is looked up using the 'object.type_map' global configuration option when necessary to support lazy loading.
Note that if multiple types are allowed and one of the allowed types is Dictionary (or a Symbol), it has to be the first in the list. Otherwise automatic type conversion functions won't work correctly.
Specifies whether this field is required.
Specifies the default value for the field, if any.
Specifies whether the value (or the values in the array value) of this field has to be an indirect object (
true), a direct object (
false) or if it doesn't matter (unspecified or
An array of allowed values for this field.
Specifies the minimum version of the PDF specification needed for this value.
Defines the static PDF type of the class in cases where this is possible, i.e. when the class implements one specific PDF type (e.g. the HexaPDF::Type::Catalog class).
Calls the block once for each field defined either in this class or in one of the ancestor classes.
Returns the field entry for the given field name.
The ancestor classes are also searched for such a field entry if none is found for the current class.
Public Instance Methods
Returns the value for the given dictionary entry.
This method should be used instead of direct access to the value because it provides numerous advantages:
References are automatically resolved.
Returns the native Ruby object for values with class HexaPDF::Object. However, all subclasses of HexaPDF::Object are returned as is (it makes no sense, for example, to return the hash that describes the Catalog instead of the Catalog object).
Automatically wraps hash values in specific subclasses of this class if field information is available (see ::define_field).
Returns the default value if one is specified and no value is available.
Deletes the name-value pair from the dictionary and returns the value. If
such a pair does not exist,
nil is returned.
Calls the given block once for every name-value entry that is stored in the dictionary.
Note that the yielded value is already preprocessed like in .
true if the dictionary contains no entries.
true if the given key is present in the dictionary and
Returns a dup of the underlying hash.