Class: Pdfrb::Model::Type::Annotation

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

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, apply_arlington_definition, arlington_default, arlington_key_to_symbol, arlington_one_type_to_ruby, arlington_required?, arlington_scalar, 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, merged_field, own_fields, #pdf_type, register_type, type_map, #validate

Methods included from Cos::ArlingtonBacked

#arlington_object

Methods inherited from Object

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

Constructor Details

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

Class Method Details

.for_subtype(symbol) ⇒ Object



89
90
91
# File 'lib/pdfrb/model/type/annotation.rb', line 89

def for_subtype(symbol)
  subtype_map[symbol]
end

.register_subtype(symbol, klass = self) ⇒ Object



85
86
87
# File 'lib/pdfrb/model/type/annotation.rb', line 85

def register_subtype(symbol, klass = self)
  subtype_map[symbol] = klass
end

.subtype_mapObject



81
82
83
# File 'lib/pdfrb/model/type/annotation.rb', line 81

def subtype_map
  @subtype_map ||= {}
end

Instance Method Details

#actionObject



44
# File 'lib/pdfrb/model/type/annotation.rb', line 44

def action; self[:A]; end

#additional_actionsObject



45
# File 'lib/pdfrb/model/type/annotation.rb', line 45

def additional_actions; self[:AA]; end

#appearanceObject



42
# File 'lib/pdfrb/model/type/annotation.rb', line 42

def appearance; self[:AP]; end

#appearance_stateObject



43
# File 'lib/pdfrb/model/type/annotation.rb', line 43

def appearance_state; self[:AS]; end

#borderObject



41
# File 'lib/pdfrb/model/type/annotation.rb', line 41

def border; self[:Border]; end

#colorObject



40
# File 'lib/pdfrb/model/type/annotation.rb', line 40

def color; self[:C]; end

#contentsObject



30
31
32
# File 'lib/pdfrb/model/type/annotation.rb', line 30

def contents
  Pdfrb::Model::Cos::TextString.decode(self[:Contents])
end

#create_appearance_streamObject



75
76
77
# File 'lib/pdfrb/model/type/annotation.rb', line 75

def create_appearance_stream
  AppearanceGenerator.for(self, document: document)&.create_appearance
end

#flagsObject



39
# File 'lib/pdfrb/model/type/annotation.rb', line 39

def flags; self[:F] || 0; end

#hidden?Boolean

---- Flag predicates ----

Returns:

  • (Boolean)


56
# File 'lib/pdfrb/model/type/annotation.rb', line 56

def hidden?; flags & 1 != 0; end

#locked?Boolean

Returns:

  • (Boolean)


62
# File 'lib/pdfrb/model/type/annotation.rb', line 62

def locked?; flags & 128 != 0; end

#locked_contents?Boolean

Returns:

  • (Boolean)


64
# File 'lib/pdfrb/model/type/annotation.rb', line 64

def locked_contents?; flags & 512 != 0; end

#modified_dateObject



38
# File 'lib/pdfrb/model/type/annotation.rb', line 38

def modified_date; self[:M]; end

#nameObject



34
35
36
# File 'lib/pdfrb/model/type/annotation.rb', line 34

def name
  Pdfrb::Model::Cos::TextString.decode(self[:NM])
end

#no_rotate?Boolean

Returns:

  • (Boolean)


59
# File 'lib/pdfrb/model/type/annotation.rb', line 59

def no_rotate?; flags & 8 != 0; end

#no_view?Boolean

Returns:

  • (Boolean)


60
# File 'lib/pdfrb/model/type/annotation.rb', line 60

def no_view?; flags & 16 != 0; end

#no_zoom?Boolean

Returns:

  • (Boolean)


58
# File 'lib/pdfrb/model/type/annotation.rb', line 58

def no_zoom?; flags & 4 != 0; end

#normal_appearanceObject

---- Appearance management ----



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

def normal_appearance
  ap = appearance
  return nil unless ap

  ap = document.object(ap) if ap.is_a?(Pdfrb::Model::Reference) && document
  ap && ap[:N]
end

#pageObject

---- Page reference ----



48
49
50
51
52
53
# File 'lib/pdfrb/model/type/annotation.rb', line 48

def page
  ref = self[:P]
  return nil unless ref && document

  document.object(ref)
end

#print?Boolean

Returns:

  • (Boolean)


57
# File 'lib/pdfrb/model/type/annotation.rb', line 57

def print?; flags & 2 != 0; end

#read_only?Boolean

Returns:

  • (Boolean)


61
# File 'lib/pdfrb/model/type/annotation.rb', line 61

def read_only?; flags & 32 != 0; end

#rectObject



28
# File 'lib/pdfrb/model/type/annotation.rb', line 28

def rect; self[:Rect]; end

#subtypeObject

---- Accessors ----



27
# File 'lib/pdfrb/model/type/annotation.rb', line 27

def subtype; self[:Subtype]; end

#toggle_no_view?Boolean

Returns:

  • (Boolean)


63
# File 'lib/pdfrb/model/type/annotation.rb', line 63

def toggle_no_view?; flags & 256 != 0; end