Closed janpeterka closed 8 months ago
I ran into a similar issue today and then noticed this section of the README. I think you're looking for that, like:
require 'bundler/setup'
require 'ostruct'
require 'prawn'
require 'prawn/grouping'
def pdf(event)
Prawn::Document.new do
event.daily_plans.each do |day|
text day.date.to_s, size: 20, style: :bold
group do |group_pdf|
day.recipes.each do |recipe|
group_pdf.text recipe.id.to_s, size: 16, style: :bold
end
end
end
end
end
event = OpenStruct.new({
daily_plans: [
OpenStruct.new({ date: '2024-08-30', recipes: [ OpenStruct.new({id: 158}) ] }),
OpenStruct.new({ date: '2024-08-31', recipes: [ OpenStruct.new({id: 236}), OpenStruct.new({id: 220}) ] }),
OpenStruct.new({ date: '2024-09-01', recipes: [ OpenStruct.new({id: 168}), OpenStruct.new({id: 221}), OpenStruct.new({id: 144}), OpenStruct.new({id: 131}) ] })
]
})
pdf(event).render_file 'out.pdf'
Thanks @woodwardjd, didn't notice this in README!
Hi, I just started with
prawn
andprawn-grouping
, and I'm having this problem:When I use
group
, everything inside it get's rendered twice. Here's minimal example code and screenshot: