Skip to content

Commit

Permalink
Make things a little bit easier for folks who want to stream their PD…
Browse files Browse the repository at this point in the history
…Fs. Thanks for the suggestion derdewey
  • Loading branch information
practicingruby committed Aug 13, 2008
1 parent d0f9d67 commit 0bfb69d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 => [])
Expand All @@ -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.
Expand Down

0 comments on commit 0bfb69d

Please sign in to comment.