diff --git a/VERSION b/VERSION index b1e80bb..845639e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.3 +0.1.4 diff --git a/lib/pdf/core/page.rb b/lib/pdf/core/page.rb index 4c4c359..b7a68a8 100644 --- a/lib/pdf/core/page.rb +++ b/lib/pdf/core/page.rb @@ -49,6 +49,7 @@ def wrap_graphics_state def new_content_stream return if in_stamp_stream? + dictionary.data = dictionary.data.dup dictionary.data[:Contents] = Array(dictionary.data[:Contents]) @content = document.ref({}) dictionary.data[:Contents] << document.state.store[@content] diff --git a/lib/prawn/templates.rb b/lib/prawn/templates.rb index c378359..34aac7d 100644 --- a/lib/prawn/templates.rb +++ b/lib/prawn/templates.rb @@ -89,7 +89,7 @@ def start_new_page(options = {}) def merge_template_options(page_options, options) object_id = state.store.import_page( options[:template], - options[:template_page] || 1 + @page_number ) page_options.merge!(object_id: object_id, page_template: true) end @@ -124,7 +124,7 @@ def import_page(input, page_num) end hash = indexed_hash(input, io) - ref = hash.page_references[page_num - 1] + ref = hash.page_references[page_num % hash.page_references.count] if ref.nil? nil diff --git a/spec/prawn/templates_spec.rb b/spec/prawn/templates_spec.rb index 5ea095f..17db144 100644 --- a/spec/prawn/templates_spec.rb +++ b/spec/prawn/templates_spec.rb @@ -418,7 +418,7 @@ sequential_pdf.render ) ) - expect(repeated_hash.size < sequential_hash.size).to be_truthy + expect(repeated_hash.size == sequential_hash.size).to be_truthy end context 'with the template as a stream' do