Class: HexaPDF::Type::Annotation

Inherits:
Dictionary show all
Extended by:
Utils::BitField
Defined in:
lib/hexapdf/type/annotation.rb

Overview

Annotations are used to associate objects like notes, sounds or movies with a location on a PDF page or allow the user to interact with a PDF document using a keyboard or mouse.

See: PDF1.7 s12.5

Defined Under Namespace

Classes: AppearanceDictionary, Border

Constant Summary

Constants included from DictionaryFields

DictionaryFields::Boolean, DictionaryFields::PDFByteString, DictionaryFields::PDFDate

Instance Attribute Summary

Attributes inherited from Object

#data, #document, #must_be_indirect

Instance Method Summary collapse

Methods included from Utils::BitField

bit_field

Methods inherited from Dictionary

#[], #[]=, define_field, define_type, #delete, #each, each_field, #empty?, field, #key?, #to_h, type, #type

Methods inherited from Object

#<=>, #==, #cache, #cached?, #clear_cache, deep_copy, #deep_copy, #document?, #eql?, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, #null?, #oid, #oid=, #type, #validate, #value, #value=

Constructor Details

This class inherits a constructor from HexaPDF::Object

Instance Method Details

#appearanceObject

Returns the AppearanceDictionary instance associated with the annotation or nil if none is set.



128
129
130
# File 'lib/hexapdf/type/annotation.rb', line 128

def appearance
  self[:AP]
end

#appearance?Boolean

Returns true if the widget’s normal appearance exists.

Note that this checks only if the appearance exists but not if the structure of the appearance dictionary conforms to the expectations of the annotation.

Returns:



136
137
138
139
140
141
# File 'lib/hexapdf/type/annotation.rb', line 136

def appearance?
  return false unless (normal_appearance = appearance&.normal_appearance)
  normal_appearance.kind_of?(HexaPDF::Stream) ||
    (!normal_appearance.empty? &&
     normal_appearance.each.all? {|_k, v| v.kind_of?(HexaPDF::Stream) })
end

#must_be_indirect?Boolean

Returns true because annotation objects must always be indirect objects.

Returns:



122
123
124
# File 'lib/hexapdf/type/annotation.rb', line 122

def must_be_indirect?
  true
end