Class: Pdfrb::Model::Type::StructElem

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/struct_elem.rb

Overview

Structure element (s14.7.4). One node in the structure tree. Holds /S (structure type), /P (parent), /K (kids), /Pg, /A, /C. Per PDF/UA Tech Note 001, /ActualText may appear for /Figure elements.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#actual_textObject



21
# File 'lib/pdfrb/model/type/struct_elem.rb', line 21

def actual_text; self[:ActualText]; end

#alt_textObject



22
# File 'lib/pdfrb/model/type/struct_elem.rb', line 22

def alt_text; self[:Alt]; end

#attributesObject



19
# File 'lib/pdfrb/model/type/struct_elem.rb', line 19

def attributes; self[:A]; end

#block_level?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/pdfrb/model/type/struct_elem.rb', line 27

def block_level?
  %i[Document Part Art Sect Div BlockQuote Caption TOC TOCI
     Index NonStruct H H1 H2 H3 H4 H5 H6 P L LI Lbl LBody
     Table TR TH TD THead TBody TFoot].include?(structure_type&.to_sym)
end

#classesObject



20
# File 'lib/pdfrb/model/type/struct_elem.rb', line 20

def classes; self[:C]; end

#each_childObject



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/pdfrb/model/type/struct_elem.rb', line 75

def each_child
  return enum_for(:each_child) unless block_given?
  return unless kids && document

  arr = kids.is_a?(Pdfrb::Model::Reference) ? document.object(kids) : kids
  return unless arr.is_a?(Array) || arr.is_a?(Pdfrb::Model::PdfArray)

  arr.each do |kid|
    obj = kid.is_a?(Pdfrb::Model::Reference) ? document.object(kid) : kid
    yield obj if obj
  end
end

#expanded_abbreviationObject



25
# File 'lib/pdfrb/model/type/struct_elem.rb', line 25

def expanded_abbreviation; self[:E]; end

#figure?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/pdfrb/model/type/struct_elem.rb', line 45

def figure?
  structure_type&.to_sym == :Figure
end

#has_actual_text?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pdfrb/model/type/struct_elem.rb', line 41

def has_actual_text?
  !!actual_text
end

#has_alt_text?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/pdfrb/model/type/struct_elem.rb', line 37

def has_alt_text?
  !!alt_text
end

#heading?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/pdfrb/model/type/struct_elem.rb', line 53

def heading?
  %i[H H1 H2 H3 H4 H5 H6].include?(structure_type&.to_sym)
end

#inline_level?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/pdfrb/model/type/struct_elem.rb', line 33

def inline_level?
  %i[Span Quote Note Reference BibEntry Code Figure Formula Form].include?(structure_type&.to_sym)
end

#kidsObject



17
# File 'lib/pdfrb/model/type/struct_elem.rb', line 17

def kids; self[:K]; end

#langObject



24
# File 'lib/pdfrb/model/type/struct_elem.rb', line 24

def lang; self[:Lang]; end

#link?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/pdfrb/model/type/struct_elem.rb', line 49

def link?
  structure_type&.to_sym == :Link
end

#pageObject



18
# File 'lib/pdfrb/model/type/struct_elem.rb', line 18

def page; self[:Pg]; end

#parentObject



16
# File 'lib/pdfrb/model/type/struct_elem.rb', line 16

def parent; self[:P]; end

#resolved_pageObject



68
69
70
71
72
73
# File 'lib/pdfrb/model/type/struct_elem.rb', line 68

def resolved_page
  ref = page
  return nil unless ref && document

  document.object(ref)
end

#resolved_parentObject



61
62
63
64
65
66
# File 'lib/pdfrb/model/type/struct_elem.rb', line 61

def resolved_parent
  ref = parent
  return nil unless ref && document

  document.object(ref)
end

#structure_typeObject



15
# File 'lib/pdfrb/model/type/struct_elem.rb', line 15

def structure_type; self[:S]; end

#table?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/pdfrb/model/type/struct_elem.rb', line 57

def table?
  structure_type&.to_sym == :Table
end

#titleObject



23
# File 'lib/pdfrb/model/type/struct_elem.rb', line 23

def title; self[:T]; end

#typeObject



14
# File 'lib/pdfrb/model/type/struct_elem.rb', line 14

def type; self[:Type]; end