Parent

Methods

PDF::Writer::TagUline

A callback to support underlining.

Constants

DEFAULT_STYLE

The default underline style.

Attributes

style[RW]

Sets the style for <c:uline> callback underlines that follow. This is expected to be a hash with the following keys:

:factor

The size of the line, as a multiple of the text height. Default is 0.05.

Set this to nil to get the default style.

Public Class Methods

[](pdf, info) click to toggle source
# File lib/pdf/writer.rb, line 2593
def [](pdf, info)
  @style ||= DEFAULT_STYLE.dup

  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       => nil
    }

    pdf.save_state
    pdf.stroke_color  @style[:color] if @style[:color]
    sz = info[:height] * @style[:factor]
    pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
  when :end, :end_line
    start = @links[info[:cbid]]
    theta = PDF::Math.deg2rad(start[:angle] - 90.0)
    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
    pdf.restore_state
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.