Class: PDF::Writer::TagIlink

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/pdf-writer/pdf/writer.rb

Overview

A callback for creating and managing links internal to the document.

Class Method Summary collapse

Class Method Details

.[](pdf, info) ⇒ Object



2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
# File 'lib/extensions/pdf-writer/pdf/writer.rb', line 2549

def self.[](pdf, info)
  case info[:status]
  when :start, :start_line
    @links ||= {}
    @links[info[:cbid]] = {
      :x         => info[:x],
      :y         => info[:y],
      :angle     => info[:angle],
      :descender => info[:descender],
      :height    => info[:height],
      :uri       => info[:params]["dest"]
    }
  when :end, :end_line
      # The end of the link. Assume that it is the most recent opening
      # which has closed.
    start = @links[info[:cbid]]
    pdf.add_internal_link(start[:uri], start[:x],
                          start[:y] + start[:descender], info[:x],
                          start[:y] + start[:descender] +
                          start[:height])
  end
end