Class: PDF::Extract::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/extract/annotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Annotation

Returns a new instance of Annotation.



7
8
9
# File 'lib/pdf/extract/annotation.rb', line 7

def initialize(data)
  @data = data || {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/pdf/extract/annotation.rb', line 5

def data
  @data
end

Instance Method Details

#as_jsonObject



33
34
35
36
37
38
39
# File 'lib/pdf/extract/annotation.rb', line 33

def as_json
  {
    "name" => name,
    "contents" => contents,
    "subtype" => subtype,
  }
end

#contentsObject

PDF Reference 6th Edition, Version 1.7, November 2006 page 606 Text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form. In either case, this text is useful when extracting the document’s contents in support of accessibility to users with disabilities or for other purposes (see Section 10.8.2, “Alternate Descriptions”). See Section 8.4.5, “Annotation Types” for more details on the meaning of this entry for each annotation type.



25
26
27
# File 'lib/pdf/extract/annotation.rb', line 25

def contents
  data[:Contents]
end

#nameObject

PDF Reference 6th Edition, Version 1.7, November 2006 page 606 The annotation name, a text string uniquely identifying it among all the annotations on its page.



14
15
16
# File 'lib/pdf/extract/annotation.rb', line 14

def name
  data[:NM]
end

#subtypeObject



29
30
31
# File 'lib/pdf/extract/annotation.rb', line 29

def subtype
  data[:Subtype]
end