| Class | Prawn::Format::Effects::Link |
| In: |
lib/prawn/format/effects/link.rb
lib/prawn/format/effects/link.rb |
| Parent: | Object |
# File lib/prawn/format/effects/link.rb, line 8
8: def initialize(target, x)
9: @target = target
10: @x = x
11: end
# File lib/prawn/format/effects/link.rb, line 8
8: def initialize(target, x)
9: @target = target
10: @x = x
11: end
# File lib/prawn/format/effects/link.rb, line 13
13: def finish(document, draw_state)
14: x1 = draw_state[:real_x] + @x
15: x2 = draw_state[:real_x] + draw_state[:dx]
16: y = draw_state[:real_y] + draw_state[:dy]
17:
18: rect = [x1, y + draw_state[:line].descent, x2, y + draw_state[:line].ascent]
19: if @target.match(/^#/)
20: document.link_annotation(rect, :Dest => @target.sub(/^#/,""), :Border => [0,0,0])
21: else
22: document.link_annotation(rect, :Border => [0,0,0], :A => { :Type => :Action, :S => :URI, :URI => Prawn::LiteralString.new(@target) } )
23: end #new
24: end
# File lib/prawn/format/effects/link.rb, line 13
13: def finish(document, draw_state)
14: x1 = draw_state[:real_x] + @x
15: x2 = draw_state[:real_x] + draw_state[:dx]
16: y = draw_state[:real_y] + draw_state[:dy]
17:
18: rect = [x1, y + draw_state[:line].descent, x2, y + draw_state[:line].ascent]
19: if @target.match(/^#/)
20: document.link_annotation(rect, :Dest => @target.sub(/^#/,""), :Border => [0,0,0])
21: else
22: document.link_annotation(rect, :Border => [0,0,0], :A => { :Type => :Action, :S => :URI, :URI => Prawn::LiteralString.new(@target) } )
23: end #new
24: end
# File lib/prawn/format/effects/link.rb, line 26
26: def wrap(document, draw_state)
27: finish(document, draw_state)
28: @x = 0
29: end