class Writer::Object::Annotation

An annotation object, this will add an annotation to the current page. initially will support just link annotations.

Constants

TYPES

Attributes

action[RW]
rect[RW]
type[RW]

Public Class Methods

new(parent, type, rect, label) click to toggle source
Calls superclass method
# File 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

Public Instance Methods

to_s() click to toggle source
# File 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