# File lib/pdf/writer.rb, line 2562
2562:       def [](pdf, info)
2563:         @style ||= DEFAULT_STYLE.dup
2564: 
2565:         case info[:status]
2566:         when :start, :start_line
2567:             # The beginning of the link. This should contain the URI for the
2568:             # link as the :params entry, and will also contain the value of
2569:             # :cbid.
2570:           @links ||= {}
2571: 
2572:           @links[info[:cbid]] = {
2573:             :x         => info[:x],
2574:             :y         => info[:y],
2575:             :angle     => info[:angle],
2576:             :descender => info[:descender],
2577:             :height    => info[:height],
2578:             :uri       => info[:params]["uri"]
2579:           }
2580: 
2581:           pdf.save_state
2582:           pdf.fill_color @style[:text_color] if @style[:text_color]
2583:           if @style[:draw_line]
2584:             pdf.stroke_color  @style[:color] if @style[:color]
2585:             sz = info[:height] * @style[:factor]
2586:             pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
2587:           end
2588:         when :end, :end_line
2589:             # The end of the link. Assume that it is the most recent opening
2590:             # which has closed.
2591:           start = @links[info[:cbid]]
2592:             # Add underlining.
2593:           theta = PDF::Math.deg2rad(start[:angle] - 90.0)
2594:           if @style[:draw_line]
2595:             drop  = start[:height] * @style[:factor] * 1.5
2596:             drop_x = Math.cos(theta) * drop
2597:             drop_y = -Math.sin(theta) * drop
2598:             pdf.move_to(start[:x] - drop_x, start[:y] - drop_y)
2599:             pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke
2600:           end
2601:           pdf.add_link(start[:uri], start[:x], start[:y] +
2602:                        start[:descender], info[:x], start[:y] +
2603:                        start[:descender] + start[:height])
2604:           pdf.restore_state
2605:         end
2606:       end