class PDF::TechBook::TagTocDots
A stand-alone callback that draws a dotted line over to the right and appends a page number. The info will be like a standard XML tag with three named parameters:
- level
-
The table of contents level that corresponds to a particular style. In the current
TechBook
implementation, there are only two levels. Level 1 uses a 16 point font and level1_style; level 2 uses a 12 point font and level2_style. - page
-
The page number that is to be printed.
- xref
-
The target destination that will be used as a link.
All parameters are required.
Constants
- DEFAULT_L1_STYLE
- DEFAULT_L2_STYLE
Attributes
level1_style[RW]
Controls the level 1 style.
level2_style[RW]
Controls the level 2 style.
Public Class Methods
[](pdf, info)
click to toggle source
# File lib/pdf/techbook.rb 312 def [](pdf, info) 313 if @level1_style.nil? 314 @level1_style = sh = DEFAULT_L1_STYLE 315 ss = PDF::Writer::StrokeStyle.new(sh[:width]) 316 ss.cap = sh[:cap] if sh[:cap] 317 ss.dash = sh[:dash] if sh[:dash] 318 @_level1_style = ss 319 end 320 if @level2_style.nil? 321 @level2_style = sh = DEFAULT_L2_STYLE 322 ss = PDF::Writer::StrokeStyle.new(sh[:width]) 323 ss.cap = sh[:cap] if sh[:cap] 324 ss.dash = sh[:dash] if sh[:dash] 325 @_level2_style = ss 326 end 327 328 level = info[:params]["level"] 329 page = info[:params]["page"] 330 xref = info[:params]["xref"] 331 332 xpos = 520 333 334 pdf.save_state 335 case level 336 when "1" 337 pdf.stroke_style @_level1_style 338 size = @level1_style[:font_size] 339 when "2" 340 pdf.stroke_style @_level2_style 341 size = @level2_style[:font_size] 342 end 343 344 page = "<c:ilink dest='#{xref}'>#{page}</c:ilink>" if xref 345 346 pdf.line(xpos, info[:y], info[:x] + 5, info[:y]).stroke 347 pdf.restore_state 348 pdf.add_text(xpos + 5, info[:y], page, size) 349 end