Created
September 2, 2014 16:02
-
-
Save Whoops/eeb4513f610301fa4368 to your computer and use it in GitHub Desktop.
Prawn_rails explanation
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' | |
# NOTE: this file won't actually run | |
# How the prawn documentation is written: | |
# provides a block without an argument, | |
# recognized methods are implicity called | |
# on the resulting PDF | |
Prawn::Document.generate("demo.pdf") do | |
move_cursor_to 50 | |
text "Hello World!" | |
end | |
# How (roughly) Prawn::Rails calls Prawn | |
# an argument is provided and all Prawn | |
# methods must be called on the pdf object | |
Prawn::Document.generate("demo2") do |pdf| | |
pdf.move_cursor_to 50 | |
pdf.text "Hello World!" | |
end | |
# Prawn document requires a block with | |
# an argument to avoid overriding many | |
# Rails methods which may be useful | |
# e.x. translate | |
prawn_document do |pdf| | |
pdf.move_cursor_to 50 | |
pdf.text "Look! I'm a PDF" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment