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. If fields differ from their superclass definition, they can be defined again in the subclass.
See: PDF2.0 s7.3.7
Public Class Methods
Defines an entry for the field
name and returns the initalized
HexaPDF::DictionaryFields::Field object. A suitable converter module (see HexaPDF::DictionaryFields::Field#converter) is selected based on the type argument.
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)
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, either
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
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::Objectare 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
Returns the default value if one is specified and no value is available.
Note: This method may throw a “can’t add a new key into hash during iteration” error in certain cases because it potentially modifies the underlying hash!
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 not
Returns a dup of the underlying hash.