Class: PDF::TechBook::TagTocDots

### Home Classes Methods

### In Files

- lib/pdf/techbook.rb

### Parent

Object

### Methods

- ::[]

### Files

- ChangeLog

### Class/Module Index

Quicksearch

- PDF
- PDF::Charts
- PDF::Charts::StdDev
- PDF::Charts::StdDev::Label
- PDF::Charts::StdDev::Marker
- PDF::Charts::StdDev::Scale
- PDF::Math
- PDF::QuickRef
- PDF::SimpleTable
- PDF::SimpleTable::Column
- PDF::SimpleTable::Column::Heading
- PDF::TechBook
- PDF::TechBook::TagTocDots
- PDF::TechBook::TagXref
- PDF::Writer
- PDF::Writer::ARC4
- PDF::Writer::Complex
- PDF::Writer::External
- PDF::Writer::FontMetrics
- PDF::Writer::Graphics
- PDF::Writer::Graphics::ImageInfo
- PDF::Writer::Graphics::ImageInfo::Formats
- PDF::Writer::Graphics::ImageInfo::Type
- PDF::Writer::Lang
- PDF::Writer::Lang::EN
- PDF::Writer::OHash
- PDF::Writer::Object
- PDF::Writer::Object::Action
- PDF::Writer::Object::Annotation
- PDF::Writer::Object::Catalog
- PDF::Writer::Object::Contents
- PDF::Writer::Object::Destination
- PDF::Writer::Object::Encryption
- PDF::Writer::Object::Font
- PDF::Writer::Object::FontDescriptor
- PDF::Writer::Object::FontEncoding
- PDF::Writer::Object::Info
- PDF::Writer::Object::Outline
- PDF::Writer::Object::Outlines
- PDF::Writer::Object::Pages
- PDF::Writer::Object::Procset
- PDF::Writer::Object::ViewerPreferences
- PDF::Writer::OffsetReader
- PDF::Writer::PolygonPoint
- PDF::Writer::State
- PDF::Writer::StateStack
- PDF::Writer::StrokeStyle

No matching classes.

# 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, 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.