lib/prawn/document.rb in prawn-1.2.1 vs lib/prawn/document.rb in prawn-1.3.0

- old
+ new

@@ -10,11 +10,10 @@ require_relative "document/bounding_box" require_relative "document/column_box" require_relative "document/internals" require_relative "document/span" -require_relative "document/graphics_state" module Prawn # The Prawn::Document class is how you start creating a PDF document. # @@ -51,11 +50,10 @@ # class Document include Prawn::Document::Internals include PDF::Core::Annotations include PDF::Core::Destinations - include Prawn::Document::GraphicsState include Prawn::Document::Security include Prawn::Text include Prawn::Graphics include Prawn::Images include Prawn::Stamp @@ -200,13 +198,13 @@ # raise NotImplementedError if options[:skip_page_creation] self.class.extensions.reverse_each { |e| extend e } @internal_state = PDF::Core::DocumentState.new(options) @internal_state.populate_pages_from_store(self) - min_version(state.store.min_version) if state.store.min_version + renderer.min_version(state.store.min_version) if state.store.min_version - min_version(1.6) if options[:print_scaling] == :none + renderer.min_version(1.6) if options[:print_scaling] == :none @background = options[:background] @background_scale = options[:background_scale] || 1 @font_size = 12 @@ -347,27 +345,17 @@ end # Renders the PDF document to string. # Pass an open file descriptor to render to file. # - def render(output = StringIO.new) - if output.instance_of?(StringIO) - output.set_encoding(::Encoding::ASCII_8BIT) + def render(*a, &b) + (1..page_count).each do |i| + go_to_page i + repeaters.each { |r| r.run(i) } end - finalize_all_page_contents - render_header(output) - render_body(output) - render_xref(output) - render_trailer(output) - if output.instance_of?(StringIO) - str = output.string - str.force_encoding(::Encoding::ASCII_8BIT) - return str - else - return nil - end + renderer.render(*a, &b) end # Renders the PDF document to file. # # pdf.render_file "foo.pdf" @@ -563,16 +551,9 @@ text_box str, opts start_count = true # increment page count as soon as first match found end pseudopage += 1 if start_count end - end - - # Returns true if content streams will be compressed before rendering, - # false otherwise - # - def compression_enabled? - !!state.compress end # @group Experimental API # Attempts to group the given block vertically within the current context.