Class: Pdfrb::Document::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfrb/document/metadata.rb

Constant Summary collapse

STANDARD_FIELDS =
%i[Title Author Subject Keywords Creator
Producer CreationDate ModDate Trapped].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Metadata

Returns a new instance of Metadata.



11
12
13
# File 'lib/pdfrb/document/metadata.rb', line 11

def initialize(document)
  @document = document
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



9
10
11
# File 'lib/pdfrb/document/metadata.rb', line 9

def document
  @document
end

Instance Method Details

#[](field) ⇒ Object



20
21
22
# File 'lib/pdfrb/document/metadata.rb', line 20

def [](field)
  read_field(field)
end

#[]=(field, value) ⇒ Object



24
25
26
# File 'lib/pdfrb/document/metadata.rb', line 24

def []=(field, value)
  write_field(field, value)
end

#to_xmpObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/pdfrb/document/metadata.rb', line 28

def to_xmp
  begin
    packet = Pdfrb::XMP::Packet.new
  rescue StandardError
    return ""
  end
  title = read_field(:Title)
  packet.title = title if title
  packet.to_xmp
end