Module: Prawn::Document::Internals

Defined in:
lib/prawn/document/internals.rb

Instance Method Summary collapse

Instance Method Details

#fresh_content_streams(options = {}) ⇒ Object

wraps existing content streams with two new streams containing just ‘q’ and ‘Q’. This ensures that prawn has a pristine graphics context before it starts adding content.

adds a new, empty content stream to each page. Used in templating so that imported content streams can be left pristine



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/prawn/document/internals.rb', line 13

def fresh_content_streams(options = {})
  (1..page_count).each do |i|
    go_to_page i

    state.page.wrap_graphics_state
    state.page.new_content_stream
    apply_margin_options(options)
    generate_margin_box
    use_graphic_settings(options[:template])
    forget_text_rendering_mode!
  end
end