18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/prawn/templates.rb', line 18
def start_new_page(options = {})
return super unless options[:template]
if last_page = state.page
last_page_size = last_page.size
last_page_layout = last_page.layout
last_page_margins = last_page.margins
end
page_options = {:size => options[:size] || last_page_size,
:layout => options[:layout] || last_page_layout,
:margins => last_page_margins}
if last_page
new_graphic_state = last_page.graphic_state.dup if last_page.graphic_state
new_graphic_state.color_space = {} if new_graphic_state
page_options.merge!(:graphic_state => new_graphic_state)
end
merge_template_options(page_options, options)
state.page = PDF::Core::Page.new(self, page_options)
apply_margin_options(options)
generate_margin_box
if last_page && (last_page.size != state.page.size ||
last_page.layout != state.page.layout)
@bounding_box = @margin_box
end
state.page.new_content_stream
use_graphic_settings(true)
forget_text_rendering_mode!
unless options[:orphan]
state.insert_page(state.page, @page_number)
@page_number += 1
canvas { image(@background, :scale => @background_scale, :at => bounds.top_left) } if @background
@y = @bounding_box.absolute_top
float do
state.on_page_create_action(self)
end
end
end
|