Class PDF::Writer::TagUline
In: lib/pdf/writer.rb
Parent: Object
Transaction::Simple SimpleTable TechBook Complex Action Procset FontDescriptor FontEncoding Destination Info Catalog Encryption Contents Pages Outline Outlines Annotation Page Font ViewerPreferences Image Hash OHash QuickRef FontMetrics ARC4 StrokeStyle PolygonPoint ImageInfo StdDev lib/pdf/simpletable.rb lib/pdf/techbook.rb lib/pdf/writer.rb lib/pdf/quickref.rb Math lib/pdf/writer/fontmetrics.rb lib/pdf/writer/ohash.rb lib/pdf/writer/arc4.rb lib/pdf/writer/strokestyle.rb lib/pdf/writer/graphics.rb lib/pdf/writer/object.rb lib/pdf/writer/object/image.rb External EN Lang OffsetReader lib/pdf/writer/graphics/imageinfo.rb Graphics lib/pdf/writer/object/outlines.rb lib/pdf/writer/object/destination.rb lib/pdf/writer/object/viewerpreferences.rb lib/pdf/writer/object/fontencoding.rb lib/pdf/writer/object/page.rb lib/pdf/writer/object/contents.rb lib/pdf/writer/object/procset.rb lib/pdf/writer/object/pages.rb lib/pdf/writer/object/info.rb lib/pdf/writer/object/encryption.rb lib/pdf/writer/object/catalog.rb lib/pdf/writer/object/outline.rb lib/pdf/writer/object/fontdescriptor.rb lib/pdf/writer/object/action.rb lib/pdf/writer/object/font.rb lib/pdf/writer/object/annotation.rb Object Writer lib/pdf/charts/stddev.rb Charts PDF dot/m_33_0.png

A callback to support underlining.

Methods

[]  

Constants

DEFAULT_STYLE = { :color => nil, :line_style => { :dash => PDF::Writer::StrokeStyle::SOLID_LINE }, :factor => 0.05   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

[Source]

      # File lib/pdf/writer.rb, line 2622
2622:       def [](pdf, info)
2623:         @style ||= DEFAULT_STYLE.dup
2624: 
2625:         case info[:status]
2626:         when :start, :start_line
2627:           @links ||= {}
2628: 
2629:           @links[info[:cbid]] = {
2630:             :x         => info[:x],
2631:             :y         => info[:y],
2632:             :angle     => info[:angle],
2633:             :descender => info[:descender],
2634:             :height    => info[:height],
2635:             :uri       => nil
2636:           }
2637: 
2638:           pdf.save_state
2639:           pdf.stroke_color  @style[:color] if @style[:color]
2640:           sz = info[:height] * @style[:factor]
2641:           pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
2642:         when :end, :end_line
2643:           start = @links[info[:cbid]]
2644:           theta = PDF::Math.deg2rad(start[:angle] - 90.0)
2645:           drop  = start[:height] * @style[:factor] * 1.5
2646:           drop_x = Math.cos(theta) * drop
2647:           drop_y = -Math.sin(theta) * drop
2648:           pdf.move_to(start[:x] - drop_x, start[:y] - drop_y)
2649:           pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke
2650:           pdf.restore_state
2651:         end
2652:       end

[Validate]