Sha256: 405ad4e82862e64a8222ce996e2d48a10d216a91e8c14c205933856066f646b0

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 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: action.rb,v 1.5 2005/05/24 22:19:42 austin Exp $
#++
  # 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
    @parent.arc4.prepare(self) if @parent.encrypted?
    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 ("
      if @parent.encrypted?
        res << PDF::Writer.escape(@parent.arc4.encrypt(@label))
      else
        res << PDF::Writer.escape(@label)
      end
      res << ")\n"
    end
    res << ">>\nendobj"
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

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