Skip to content

Instantly share code, notes, and snippets.

@Whoops
Created September 2, 2014 16:02
Show Gist options
  • Save Whoops/eeb4513f610301fa4368 to your computer and use it in GitHub Desktop.
Save Whoops/eeb4513f610301fa4368 to your computer and use it in GitHub Desktop.
Prawn_rails explanation
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