class

PDF::Objects::Dictionary

Inherits PDF::Objects::Base < Reference < Object

Represents a PDF dictionary object.

A PDF dictionary is an associative table of name-value pairs. Keys must be Name objects; values can be any PDF object type.

dict = PDF::Objects::Dictionary.new
dict[PDF::Objects::Name::TYPE] = PDF::Objects::Name::PAGE
dict[PDF::Objects::Name.new("Count")] = PDF::Objects::Number.new(5)
dict.to_pdf # => "<</Type /Page /Count 5>>"

Constructors

new(entries : Hash(Name, Base))
Source

Instance methods

==(other : self)

Returns true if this reference is the same as other. Invokes same?.

[](key : Name) : Base

Get a value by Name

Source
[](key : String) : Base

Get a value by string key (convenience method)

Source
[]=(key : Name, value : Base) : Base

Set a value by Name

Source
[]=(key : String, value : Base) : Base

Set a value by string key (convenience method)

Source
[]?(key : Name) : Base | Nil

Get a value by Name, returning nil if not found

Source
[]?(key : String) : Base | Nil

Get a value by string key, returning nil if not found

Source
clear
Source
delete(key : Name) : Base | Nil

Delete a key

Source
delete(key : String) : Base | Nil

Delete a string key

Source
each

Iterate over entries

Source
empty?
Source
has_key?(key : Name) : Bool

Check if a key exists

Source
has_key?(key : String) : Bool

Check if a string key exists

Source
hash(hasher)

See Object#hash(hasher)

keys

Get all keys

Source
merge!(other : Dictionary) : self

Merge another dictionary into this one

Source
size
Source
to_pdf(io : IO) : Nil

Serializes this object to an IO.

By default, this writes the result of #to_pdf to the IO. Subclasses may override for more efficient streaming.

Source
to_pdf

Serializes this object to PDF syntax.

Returns the PDF representation as a string.

Source
values

Get all values

Source