Prawn pdf group, transaction and rollback issues

I am trying to create a pdf report using shrimp in a rails application. There are many sections containing user-created content that I want to try and combine together. Sometimes this will go over more than one page, due to which it is not possible to group the error. Then I tried to use a transaction so that in case of an error I could roll back and then output the contents without using the group method.

The problem is that rollback loads pages. Deletes an extra page from pdf, but still has the wrong page count and prints on lapped content when I try to redo it. I reset the y position after the rollback, according to the shrimp documentation, but I'm still having problems.

eg. The following test code writes 2 pages of numbers, rolls back to the beginning, and then tries to write the same numbers again. This results in a single page pdf page with a second page of numbers overlapping the first and the number of pages at 2. The number of pages at the bottom of the page also overlaps, although I use the prawn number_pages method

class TestReport < Prawn::Document 
  def to_pdf   
    font('Helvetica')
  bounding_box([bounds.left, bounds.top - 50], :width  => bounds.width, :height => bounds.height - 100) do   

text 'begin'
  y_pos = y
  transaction do
    begin
      group do
        64.times do|i|
          text i.to_s
        end
      end
    rescue
      rollback
    end
  end
  self.y = y_pos

  64.times do|i|
    text i.to_s
  end

  text 'end'
  text page_number.to_s
end

    page_numbers(1)
    #render
  end

 def page_numbers(start)
    string = "page <page> of <total>"
    options = { :at => [bounds.right - 150, 40],
              :width => 150,
              :align => :right,
              :start_count_at => start,
              :color => "000000" }
    number_pages string, options
 end
end

 def test_report
    pdf = TestReport.new()
     pdf.to_pdf
     send_data pdf.render, filename: "test.pdf",
                      type: "application/pdf",
                      disposition: "inline"
 end

, , . , , - . ?

? - , .

- rails (gem 'prawn',: git = > 'git://github.com/prawnpdf/prawn.git',: branch = > 'master').

+3
2

, , Google .

- (v 1.0.0.rc2), , , , , , .

def group_if_possible(pdf, &block)
  begin
    pdf.group { block.call }
  rescue Prawn::Errors::CannotGroup
    block.call
  end
end

: :

group_if_possible(pdf) do
  pdf.table(rows)
end

EDIT:
1.x, , 2: https://github.com/ddengler/prawn-grouping

+3

, Google Groups, -, , :

, , . :

https://github.com/prawnpdf/prawn/issues/268

-be

+1
source