-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-page text overlaps repeating header #1160
Comments
Worked around this issue using a Here is how this would apply to your code: def initialize(order, view)
super(top_margin: 15)
@order = order
@view = view
repeat(:all) do
text "Envelope ID: CA7C190B-6ED5-44C5-95F0-36D49EC3CA38"
@repeat_height = y # Store repeated content height
end
# Prevent text from overlapping repeated content
bounding_box([bounds.left, bounds.top - @repeat_height], width: bounds.width, height: bounds.height - @repeat_height) do
text "#{@order.document_template.content.to_plain_text}", size: 12
end
string = "page <page> of <total>"
options = {
:at => [bounds.right - 150, 0], :width => 150,
:align => :right,
:page_filter => (1..7), :start_count_at => 1,
:color => "007700" }
number_pages string, options
end |
Thanks for the clue on this! I was working on a similar problem, and although I had to shift around some of the calculations, this approach worked great for me. I ended up with roughly: prawn_doc.repeat(:all) do
# Draw the header
repeat_height = prawn_doc.cursor
end
prawn_doc.bounding_box(
[prawn_doc.bounds.left, repeat_height],
width: prawn_doc.bounds.width,
height: repeat_height
) do
# draw _all_ the rest of the document content, regardless of pages
end I'm still getting started with Prawn, so I'm not quite sure why had to use |
Thanks @goulvench for sharing solution. I am using
Here is the solution that worked for me repeat(:all) do
...
....
@repeat_box_height = cursor # Store repeated content height
end
bounding_box([bounds.left, @repeat_box_height], width: bounds.width, height: @repeat_box_height) do
...
....
end |
I have a repeat(:all) action to act as a header on every page. However, the main content I am printing out spans across multiple pages and text will flow to the next page overlapping the header. How can I get Prawn to respect the header? move_down 20 doesn't work for the subsequent pages.
The text was updated successfully, but these errors were encountered: