ddengler / prawn-grouping

A gem to add a more flexible grouping option to the prawn gem
https://github.com/ddengler/prawn-grouping
MIT License
14 stars 21 forks source link

Grouping only works with implied block form #14

Closed bjorntrondsen closed 9 years ago

bjorntrondsen commented 9 years ago

Hello The following works as expected:

    Prawn::Document.new do
      group do
        40.times { text "1111" }
      end

      group do
        40.times { text "222" }
      end
    end

If I change to explicit block form, then the content is rendered twice and grouping doesnt happen:

    Prawn::Document.new do |pdf|
      pdf.group do
        40.times { pdf.text "1111" }
      end

      pdf.group do
        40.times { pdf.text "222" }
      end
    end

Tested with Prawn 1.3.0 and the latest version of prawn-grouping from github/master

ddengler commented 9 years ago

Thanks for the report. Will look into it.

ddengler commented 9 years ago

Sorry for the late reply. This probably happens because you reference the original document within your group by using pdf.text in the curly braces. The following should also work:

Prawn::Document.new do |pdf|
    pdf.group do |group_pdf|
        40.times { group_pdf.text "1111" }
    end

    pdf.group do  |group_pdf|
        40.times { group_pdf.text "222" }
    end
end