Class: PDF::Writer::TagUline
- Inherits:
-
Object
- Object
- PDF::Writer::TagUline
- Defined in:
- lib/pdf/writer.rb
Overview
A callback to support underlining.
Constant Summary collapse
- DEFAULT_STYLE =
The default underline style.
{ :color => nil, :line_style => { :dash => PDF::Writer::StrokeStyle::SOLID_LINE }, :factor => 0.05 }
Class Attribute Summary collapse
-
.style ⇒ Object
Sets the style for <c:uline> callback underlines that follow.
Class Method Summary collapse
Class Attribute Details
.style ⇒ Object
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.
2591 2592 2593 |
# File 'lib/pdf/writer.rb', line 2591 def style @style end |
Class Method Details
.[](pdf, info) ⇒ Object
2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 |
# 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 |