Sha256: f1ddfb01c95359b440760dc4ce9df43a367caa8196f4236580792f3cafbfe2a8

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

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: action.rb 190 2007-12-11 07:16:27Z sandal $
#++
  # An action object, used to link to URLS initially
class PDF::Writer::Object::Action < PDF::Writer::Object
  def initialize(parent, label, type = "URI")
    super(parent)

    @type   = type
    @label  = label
    raise TypeError if @label.nil?
  end

  attr_accessor :type
  attr_accessor :label

  def to_s
    res = "\n#{@oid} 0 obj\n<< /Type /Action"
    if @type == :ilink
      res << "\n/S /GoTo\n/D #{@parent.destinations[@label].oid} 0 R"
    elsif @type == 'URI'
      res << "\n/S /URI\n/URI ("
      res << PDF::Writer.escape(@label)
      res << ")\n"
    end
    res << ">>\nendobj"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdf-writer-1.1.6 lib/pdf/writer/object/action.rb