A callback to support the formation of clickable links to external locations.
The default anchored link style.
Sets the style for <c:alink> callback underlines that follow. This is expected to be a hash with the following keys:
:color |
The colour to be applied to the link underline. Default is Color::RGB::Blue. |
:text_color |
The colour to be applied to the link text. Default is Color::RGB::Blue. |
:factor |
The size of the line, as a multiple of the text height. Default is 0.05. |
:draw_line |
Whether to draw the underline as part of the link or not. Default is true. |
:line_style |
The style modification hash supplied to PDF::Writer::StrokeStyle.new. The default is a solid line with normal cap, join, and miter limit values. |
Set this to nil to get the default style.
# File lib/pdf/writer.rb, line 2498 def [](pdf, info) @style ||= DEFAULT_STYLE.dup case info[:status] when :start, :start_line # The beginning of the link. This should contain the URI for the # link as the :params entry, and will also contain the value of # :cbid. @links ||= {} @links[info[:cbid]] = { :x => info[:x], :y => info[:y], :angle => info[:angle], :descender => info[:descender], :height => info[:height], :uri => info[:params]["uri"] } pdf.save_state pdf.fill_color @style[:text_color] if @style[:text_color] if @style[:draw_line] pdf.stroke_color @style[:color] if @style[:color] sz = info[:height] * @style[:factor] pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style]) end when :end, :end_line # The end of the link. Assume that it is the most recent opening # which has closed. start = @links[info[:cbid]] # Add underlining. theta = PDF::Math.deg2rad(start[:angle] - 90.0) if @style[:draw_line] drop = start[:height] * @style[:factor] * 1.5 drop_x = Math.cos(theta) * drop drop_y = -Math.sin(theta) * drop pdf.move_to(start[:x] - drop_x, start[:y] - drop_y) pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke end pdf.add_link(start[:uri], start[:x], start[:y] + start[:descender], info[:x], start[:y] + start[:descender] + start[:height]) pdf.restore_state end end
Generated with the Darkfish Rdoc Generator 2.