-
-
Save practicingruby/8151718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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