Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make things a little bit easier for folks who want to stream their PD…

…Fs. Thanks for the suggestion derdewey
  • Loading branch information...
commit 0bfb69d47d3c53f9377a5c2b3dabee489dc4e174 1 parent d0f9d67
@practicingruby practicingruby authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/prawn/document.rb
View
11 lib/prawn/document.rb
@@ -43,8 +43,7 @@ class Document
# end
#
def self.generate(filename,options={},&block)
- pdf = Prawn::Document.new(options)
- block.arity < 1 ? pdf.instance_eval(&block) : yield(pdf)
+ pdf = Prawn::Document.new(options,&block)
pdf.render_file(filename)
end
@@ -72,7 +71,7 @@ def self.generate(filename,options={},&block)
# pdf = Prawn::Document.new(:on_page_start =>
# lambda { |doc| doc.line [0,100], [300,100] } )
#
- def initialize(options={})
+ def initialize(options={},&block)
@objects = []
@info = ref(:Creator => "Prawn", :Producer => "Prawn")
@pages = ref(:Type => :Pages, :Count => 0, :Kids => [])
@@ -92,7 +91,11 @@ def initialize(options={})
@bounding_box = @margin_box
- start_new_page unless options[:skip_page_creation]
+ start_new_page unless options[:skip_page_creation]
+
+ if block
+ block.arity < 1 ? instance_eval(&block) : block[self]
+ end
end
# Creates and advances to a new page in the document.
Please sign in to comment.
Something went wrong with that request. Please try again.