Class: HexaPDF::Type::Annotation
- Inherits:
-
Dictionary
- Object
- Object
- Dictionary
- HexaPDF::Type::Annotation
- 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
Direct Known Subclasses
HexaPDF::Type::Annotations::Link, HexaPDF::Type::Annotations::MarkupAnnotation, HexaPDF::Type::Annotations::Widget, IconFit
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
-
#appearance(type = :normal) ⇒ Object
(also: #appearance?)
Returns the annotation's appearance stream of the given type (:normal, :rollover, or :down) or
nilif it doesn't exist. -
#appearance_dict ⇒ Object
Returns the AppearanceDictionary instance associated with the annotation or
nilif none is set. -
#must_be_indirect? ⇒ Boolean
Returns
truebecause annotation objects must always be indirect objects.
Methods included from Utils::BitField
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
#appearance(type = :normal) ⇒ Object Also known as: appearance?
Returns the annotation's appearance stream of the given type (:normal, :rollover, or :down) or nil if it doesn't exist.
The appearance state is taken into account if necessary.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/hexapdf/type/annotation.rb', line 136 def appearance(type = :normal) entry = appearance_dict&.send("#{type}_appearance") if entry.kind_of?(HexaPDF::Dictionary) && !entry.kind_of?(HexaPDF::Stream) entry = entry[self[:AS]] end return unless entry.kind_of?(HexaPDF::Stream) if entry.type == :XObject && entry[:Subtype] == :Form entry elsif (entry[:Type].nil? || entry[:Type] == :XObject) && (entry[:Subtype].nil? || entry[:Subtype] == :Form) && entry[:BBox] document.wrap(entry, type: :XObject, subtype: :Form) end end |
#appearance_dict ⇒ Object
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_dict self[:AP] end |
#must_be_indirect? ⇒ Boolean
Returns true because annotation objects must always be indirect objects.
122 123 124 |
# File 'lib/hexapdf/type/annotation.rb', line 122 def must_be_indirect? true end |