Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created December 27, 2013 19:50
Show Gist options
  • Select an option

  • Save practicingruby/8151718 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/8151718 to your computer and use it in GitHub Desktop.
require "prawn"
class CustomReport
def initialize(document)
@document = document
end
def header(message)
draw { text(message, :size => 32) }
end
def body(message)
draw do
move_down 10
text(message, :size => 10)
end
end
def draw(&block)
@document.instance_eval(&block)
end
end
doc = Prawn::Document.new
report = CustomReport.new(doc)
report.header("Hello World")
report.body("The rain in spain falls mainly on the plains. " * 20)
doc.render_file("example.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment