Class PDF::Writer::TagUline
In: lib/pdf/writer.rb
Parent: Object
TechBook Transaction::Simple SimpleTable Complex Action FontDescriptor Procset Catalog FontEncoding Pages Destination Info Encryption Annotation Contents Outline Page Outlines Font ViewerPreferences Image Hash OHash QuickRef StdDev FontMetrics StrokeStyle ARC4 PolygonPoint ImageInfo lib/pdf/simpletable.rb lib/pdf/writer.rb lib/pdf/techbook.rb lib/pdf/quickref.rb lib/pdf/charts/stddev.rb Charts Math lib/pdf/writer/ohash.rb lib/pdf/writer/fontmetrics.rb lib/pdf/writer/strokestyle.rb lib/pdf/writer/arc4.rb lib/pdf/writer/graphics.rb lib/pdf/writer/object.rb lib/pdf/writer/object/image.rb External lib/pdf/writer/object/font.rb lib/pdf/writer/object/outlines.rb lib/pdf/writer/object/contents.rb lib/pdf/writer/object/annotation.rb lib/pdf/writer/object/destination.rb lib/pdf/writer/object/viewerpreferences.rb lib/pdf/writer/object/info.rb lib/pdf/writer/object/fontencoding.rb lib/pdf/writer/object/page.rb lib/pdf/writer/object/catalog.rb lib/pdf/writer/object/outline.rb lib/pdf/writer/object/encryption.rb lib/pdf/writer/object/procset.rb lib/pdf/writer/object/action.rb lib/pdf/writer/object/pages.rb lib/pdf/writer/object/fontdescriptor.rb Object OffsetReader EN Lang lib/pdf/writer/graphics/imageinfo.rb Graphics Writer 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 2593
2593:       def [](pdf, info)
2594:         @style ||= DEFAULT_STYLE.dup
2595: 
2596:         case info[:status]
2597:         when :start, :start_line
2598:           @links ||= {}
2599: 
2600:           @links[info[:cbid]] = {
2601:             :x         => info[:x],
2602:             :y         => info[:y],
2603:             :angle     => info[:angle],
2604:             :descender => info[:descender],
2605:             :height    => info[:height],
2606:             :uri       => nil
2607:           }
2608: 
2609:           pdf.save_state
2610:           pdf.stroke_color  @style[:color] if @style[:color]
2611:           sz = info[:height] * @style[:factor]
2612:           pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
2613:         when :end, :end_line
2614:           start = @links[info[:cbid]]
2615:           theta = PDF::Math.deg2rad(start[:angle] - 90.0)
2616:           drop  = start[:height] * @style[:factor] * 1.5
2617:           drop_x = Math.cos(theta) * drop
2618:           drop_y = -Math.sin(theta) * drop
2619:           pdf.move_to(start[:x] - drop_x, start[:y] - drop_y)
2620:           pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke
2621:           pdf.restore_state
2622:         end
2623:       end

[Validate]