Class: PDF::Extract::Document

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

Constant Summary collapse

PAGE_ANNOTATIONS_KEY =
:Annots

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ Document

Returns a new instance of Document.



9
10
11
# File 'lib/pdf/extract/document.rb', line 9

def initialize(path:)
  @document = ::PDF::Reader.new(path)
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
end

Instance Method Details

#annotationsObject



13
14
15
16
17
# File 'lib/pdf/extract/document.rb', line 13

def annotations
  reference_resoler.lookup(annotation_references).map { |h|
    Annotation.new(h)
  }
end

#fieldsObject



19
20
21
22
23
# File 'lib/pdf/extract/document.rb', line 19

def fields
  reference_resoler.lookup(field_references).map { |h|
    Field.new(h, reference_resoler)
  }
end