Class: PDF::Writer::Object::Annotation
- Inherits:
-
PDF::Writer::Object
- Object
- PDF::Writer::Object
- PDF::Writer::Object::Annotation
- Defined in:
- lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb
Overview
An annotation object, this will add an annotation to the current page. initially will support just link annotations.
Constant Summary collapse
- TYPES =
[:link, :ilink]
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#rect ⇒ Object
Returns the value of attribute rect.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from PDF::Writer::Object
Instance Method Summary collapse
-
#initialize(parent, type, rect, label) ⇒ Annotation
constructor
A new instance of Annotation.
- #to_s ⇒ Object
Constructor Details
#initialize(parent, type, rect, label) ⇒ Annotation
Returns a new instance of Annotation.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb', line 16 def initialize(parent, type, rect, label) super(parent) @type = type @rect = rect case @type when :link @action = PDF::Writer::Object::Action.new(parent, label) when :ilink @action = PDF::Writer::Object::Action.new(parent, label, type) end parent.current_page.add_annotation(self) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
32 33 34 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb', line 32 def action @action end |
#rect ⇒ Object
Returns the value of attribute rect.
33 34 35 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb', line 33 def rect @rect end |
#type ⇒ Object
Returns the value of attribute type.
31 32 33 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb', line 31 def type @type end |
Instance Method Details
#to_s ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb', line 35 def to_s res = "\n#{@oid} 0 obj\n<< /Type /Annot" res << "\n/Subtype /Link" if TYPES.include?(@type) res << "\n/A #{@action.oid} 0 R\n/Border [0 0 0]\n/H /I\n/Rect [" @rect.each { |v| res << "%.4f " % v } res << "]\n>>\nendobj" end |