Skip to content

Instantly share code, notes, and snippets.

@HHRy
Created October 25, 2010 22:21
Show Gist options
  • Save HHRy/645910 to your computer and use it in GitHub Desktop.
Save HHRy/645910 to your computer and use it in GitHub Desktop.
A little example of what I'm working on just now, Prawn::Graph version two and Prawn::BackgroundDocument, a way to offload the generation of complicated PDFs.
require 'prawn'
require 'prawn/graph'
require 'prawn/background_document'
require 'active_record'
Prawn::BackgroundDocument.generate('some_file.pdf', :callback => [ :completed, :failure ]) do |pdf|
pdf.bar_graph Bees.where('number_spotted > 0').order('number_spotted'), :best_fit
end
def completed
puts "PDF Generation worked!"
end
def failure
puts "PDF Generation failed!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment