Sha256: 706b288ab11e16e54441866b542f4ce8fdc7bf79cd9df03c0bdc05bff660e3c8

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

#--
# PDF::Writer for Ruby.
#   http://rubyforge.org/projects/ruby-pdf/
#   Copyright 2003 - 2005 Austin Ziegler.
#
#   Licensed under a MIT-style licence. See LICENCE in the main distribution
#   for full licensing information.
#
# $Id: annotation.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
#++
  # An annotation object, this will add an annotation to the current page.
  # initially will support just link annotations.
class PDF::Writer::Object::Annotation < PDF::Writer::Object
  TYPES = [:link, :ilink]

  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

  attr_accessor :type
  attr_accessor :action
  attr_accessor :rect

  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
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
pdf-labels-1.0.0 vendor/pdf/writer/object/annotation.rb
pdf-labels-1.0.1 vendor/pdf/writer/object/annotation.rb
pdf-labels-2.0.1 vendor/pdf/writer/object/annotation.rb
pdf-writer-1.0.0 lib/pdf/writer/object/annotation.rb
pdf-writer-1.1.2 lib/pdf/writer/object/annotation.rb
pdf-writer-1.1.0 lib/pdf/writer/object/annotation.rb
pdf-writer-1.1.3 lib/pdf/writer/object/annotation.rb
pdf-writer-1.0.1 lib/pdf/writer/object/annotation.rb
pdf-writer-1.1.1 lib/pdf/writer/object/annotation.rb