lib/prawn/document.rb in prawn-0.1.1 vs lib/prawn/document.rb in prawn-0.1.2
- old
+ new
@@ -57,10 +57,11 @@
# <tt>:left_margin</tt>:: Sets the left margin in points [ 0.5 inch]
# <tt>:right_margin</tt>:: Sets the right margin in points [ 0.5 inch]
# <tt>:top_margin</tt>:: Sets the top margin in points [ 0.5 inch]
# <tt>:bottom_margin</tt>:: Sets the bottom margin in points [0.5 inch]
# <tt>:skip_page_creation</tt>:: Creates a document without starting the first page [false]
+ # <tt>:compress</tt>:: Compresses content streams before rendering them [false]
#
#
# # New document, US Letter paper, portrait orientation
# pdf = Prawn::Document.new
#
@@ -75,13 +76,14 @@
@objects = []
@info = ref(:Creator => "Prawn", :Producer => "Prawn")
@pages = ref(:Type => :Pages, :Count => 0, :Kids => [])
@root = ref(:Type => :Catalog, :Pages => @pages)
@page_start_proc = options[:on_page_start]
- @page_stop_proc = options[:on_page_end]
+ @page_stop_proc = options[:on_page_stop]
@page_size = options[:page_size] || "LETTER"
@page_layout = options[:page_layout] || :portrait
+ @compress = options[:compress] || false
@margins = { :left => options[:left_margin] || 36,
:right => options[:right_margin] || 36,
:top => options[:top_margin] || 36,
:bottom => options[:bottom_margin] || 36 }
@@ -237,10 +239,15 @@
stored = {}
fields.each { |f| stored[f] = send(f) }
yield
fields.each { |f| send("#{f}=", stored[f]) }
end
+
+ def compression_enabled?
+ @compress
+ end
+
private
def generate_margin_box
old_margin_box = @margin_box
@@ -284,9 +291,10 @@
end
def finish_page_content
@page_stop_proc[self] if @page_stop_proc
add_content "Q"
+ @page_content.compress_stream if compression_enabled?
@page_content.data[:Length] = @page_content.stream.size
end
# Write out the PDF Header, as per spec 3.4.1
def render_header(output)