Parent

Methods

Files

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.

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, line 312
def [](pdf, info)
  if @level1_style.nil?
    @level1_style = sh = DEFAULT_L1_STYLE
    ss      = PDF::Writer::StrokeStyle.new(sh[:width])
    ss.cap  = sh[:cap] if sh[:cap]
    ss.dash = sh[:dash] if sh[:dash]
    @_level1_style = ss
  end
  if @level2_style.nil?
    @level2_style = sh = DEFAULT_L2_STYLE
    ss      = PDF::Writer::StrokeStyle.new(sh[:width])
    ss.cap  = sh[:cap] if sh[:cap]
    ss.dash = sh[:dash] if sh[:dash]
    @_level2_style = ss
  end

  level = info[:params]["level"]
  page  = info[:params]["page"]
  xref  = info[:params]["xref"]

  xpos = 520

  pdf.save_state
  case level
  when "1"
    pdf.stroke_style @_level1_style
    size = @level1_style[:font_size]
  when "2"
    pdf.stroke_style @_level2_style
    size = @level2_style[:font_size]
  end

  page = "<c:ilink dest='#{xref}'>#{page}</c:ilink>" if xref

  pdf.line(xpos, info[:y], info[:x] + 5, info[:y]).stroke
  pdf.restore_state
  pdf.add_text(xpos + 5, info[:y], page, size)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.