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

Document#group has been disabled #21

Closed pepa65 closed 7 years ago

pepa65 commented 7 years ago

So I did gem install prawn-grouping in the hope of getting group functionality, hoping it would override Prawn's regular NotImplementedError on the use of group. But it still doesn't work. Is there a trick to getting it to work? Or is there no hope since Prawn gave up??

jdraths commented 7 years ago

I've gotten it to work before, share your usage code.

Here's an example of how I did it:

group do |g|
    g.table(data, column_widths: [26 + 514]) do
        cells.font_style = :bold
        cells.background_color = "e4e4e4"
    end
end
pepa65 commented 7 years ago

I got this version installed by uninstalling the normal prawn gems and then:

git clone http://github.com/ddengler/prawn.git
cd prawn
gem build prawn.gemspec
sudo gem install prawn-1.0.0.gem

It's not working perfectly, but I think I will try the prawn-grouping extension. Example:

require "prawn"

Prawn::Document.generate("avid.pdf") do
  default_leading 12

  font("/home/pp/.fonts/ArundinaSerif-Bold.ttf", :size => 50, :kerning => true)
  fill_color "222222"
  text "เพลงนม?สการ", :size => 50, :style => :bold, :character_spacing => 1
  move_down 20

group do
  move_down 12
  font("/home/pp/.fonts/ArundinaSerif-Bold.ttf", :size => 24, :kerning => true)
  text "ข้อสรรเสริญ", :size => 16, :style => :bold
  move_down 6
    font("/home/pp/.fonts/ArundinaSerif.ttf", :size => 16, :kerning => true)
    text "สรรเสริญพระเจ้าผู้อำนวยพร"
    text "สรรเสริญพระเจ้าเหล่าประชากร"
    text "สรรเสริญองค์พระบิดาพระบุตร"
    text "สรรเสริญพระวิญญาณบริสุทธิ์"
    text "อาเมน"
end
# And many more groups like this

end
pepa65 commented 7 years ago

I similarly installed prawn-grouping, and then changed all the group do into group :too_tall => lambda {start_new_page} do. Some empty pages, some orphaned lines... It sometime works, but on the whole, not good enough... :-(