sandal (owner)

Revisions

gist: 178065 Download_button fork
public
Public Clone URL: git://gist.github.com/178065.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require "prawn/core"
 
class Prawn::Document
  def go_to_page(k)
    jump_to = @store.pages.data[:Kids][k]
    @current_page = jump_to.identifier
    @page_content = jump_to.data[:Contents].identifier
  end
 
  def number_pages(string, position)
    page_count.times do |i|
      go_to_page(i)
      str = string.gsub("<page>","#{i+1}").gsub("<total>","#{page_count}")
      text str, :at => position
    end
  end
end
 
Prawn::Document.generate("crappoop.pdf") do
  text "Hai"
  start_new_page
  text "bai"
  start_new_page
  text "-- Hai again"
  number_pages "<page> in a total of <total>", [bounds.right - 50, 0]
end