Sha256: c0013627a6818bdd8716a42e19448c0de3aac9f86236a94e020f50d058a3be5e

Contents?: true

Size: 1.37 KB

Versions: 11

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8
#
# This example demonstrates the use of the the outlines option for a new document
# it sets an initial outline item with a title
#
require "#{File.dirname(__FILE__)}/../example_helper.rb"

Prawn::Document.generate('outlines.pdf') do
  text "Page 1. This is the first Chapter. "
  start_new_page
  text "Page 2. More in the first Chapter. "
  start_new_page
  text "Page 3. This is the second Chapter. It has a subsection. "
  start_new_page
  text  "Page 4. More in the second Chapter. "
  define_outline do
    section 'Chapter 1', :page => 1, :closed => true do 
      page 1, :title => 'Page 1'
      page 2, :title => 'Page 2'
    end
    section 'Chapter 2', :page => 3 do 
      section 'Chapter 2 Subsection' do
        page nil,  :title => 'Page 3'
      end
      page 4, :title => 'Page 4'
    end
  end
  start_new_page
  text "Page 5. Appendix"
  start_new_page 
  text "Page 6. More in the Appendix"
  outline.add_section do
    section 'Appendix', :page => 5 do
      page 5, :title => 'Page 5'
      page 6, :title => 'Page 6'
    end
  end
  go_to_page 4
  start_new_page 
  text "inserted before the Appendix"
  outline.insert_section_after 'Chapter 2' do
    page page_number, :title => "Pre-Appendix"
  end
  go_to_page 7
  start_new_page
  text "One last page"
  outline.insert_section_after 'Page 6' do 
    page page_number, :title => "Inserted after 6"
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
piglop-prawn-0.10.2.3 examples/general/outlines.rb
piglop-prawn-0.10.2.2 examples/general/outlines.rb
piglop-prawn-0.10.2.1 examples/general/outlines.rb
alphasights-prawn-0.10.4 examples/general/outlines.rb
alphasights-prawn-0.10.3 examples/general/outlines.rb
alphasights-prawn-0.10.2 examples/general/outlines.rb
alphasights-prawn-0.10.1 examples/general/outlines.rb
alphasights-prawn-0.10.0 examples/general/outlines.rb
prawn-core-0.8.4 examples/general/outlines.rb
prawn-graph-0.0.2 vendor/prawn-core/examples/general/outlines.rb
prawn-graph-0.0.1 vendor/prawn-core/examples/general/outlines.rb