Sha256: 42baa74f906ae6ab72e20cb9dda0d946a28609e180eb92e8db127d3d2d19dd98

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 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$
#++
  # 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(@parent.arc4.nil? ? @label : @parent.arc4.encrypt(@label))
      res << ")\n"
    end
    res << ">>\nendobj"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ypdf-writer-1.3.5 lib/pdf/writer/object/action.rb
ypdf-writer-1.3.3 lib/pdf/writer/object/action.rb
ypdf-writer-1.3.2 lib/pdf/writer/object/action.rb