Skip to content

Instantly share code, notes, and snippets.

@rivsc
Created November 14, 2011 15:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rivsc/1364163 to your computer and use it in GitHub Desktop.
Prawn #rollback method is broken
require 'rubygems'
require 'prawn'
Prawn::Document.generate("make_a_broken.pdf") do |pdf|
pdf.font_size 12
pdf.move_down 20
pdf.font "Helvetica"
# We use the rollback method so the text in this block should not be displayed
pdf.transaction do
30.times{ |i|
10.times{
pdf.text "Never display #{i}"
}
}
pdf.rollback # Comment this line
end
# This text must be displayed
30.times{ |i|
10.times{
pdf.text "This is a text #{i}"
}
}
pdf.number_pages 'Page <page> of <total>', { :at => [pdf.bounds.bottom + 300, 15] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment