Skip to content
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

Repeaters affect cursor position #523

Closed
JacobEvelyn opened this issue Jul 25, 2013 · 7 comments
Closed

Repeaters affect cursor position #523

JacobEvelyn opened this issue Jul 25, 2013 · 7 comments

Comments

@JacobEvelyn
Copy link

Correct me if I'm wrong, but I believe this is abnormal behavior:

pdf = Prawn::Document.new(margin: 100)
puts "Cursor before regular repeater: #{pdf.cursor}"
pdf.repeat(:all) do
  pdf.canvas do
  end
end
puts "Cursor after regular repeater: #{pdf.cursor}"

pdf = Prawn::Document.new(margin: 100)
puts "Cursor before dynamic repeater: #{pdf.cursor}"
pdf.repeat(:all, dynamic: true) do
  pdf.canvas do
  end
end
puts "Cursor after dynamic repeater: #{pdf.cursor}"

Output:

Cursor before regular repeater: 592.0
Cursor after regular repeater: 692.0

Cursor before dynamic repeater: 592.0
Cursor after dynamic repeater: 592.0

Shouldn't both dynamic and non-dynamic repeaters leave the cursor at 592.0 after they're defined?

@JacobEvelyn
Copy link
Author

Is this behavior correct?

@practicingruby
Copy link
Member

Hi, we did a bulk close on issues that did not see activity in the last month or so, because the project has been mostly unmaintained for the last several months.

I made an announcement on the Prawn mailing list about this, with the intention of re-opening any ticket that still had someone interested in it.

I've re-opened this one and removed the 'stale' tag, and will investigate as I work through the review queue. Thanks!

@JacobEvelyn
Copy link
Author

Ah, thanks for the explanation.

@practicingruby
Copy link
Member

I've confirmed that the issue above exists in master, and I agree, it's the wrong behavior. Does someone want to investigate this one?

@practicingruby
Copy link
Member

@JacobEvelyn: I think this may actually be a bug in canvas... I'll dig deeper and see what I can find.

practicingruby added a commit that referenced this issue Dec 20, 2013
This is a clarification on the desired behavior of bounding boxes, which
essentially states that if the user does not modify the y
position in a bounding box that is either stretchy or
has its position held, the original y position will be restored.

The only realistic condition I can think of for this is
when doing vector drawings which do not actually modify the cursor
position, or possibly when doing conditional logic within a bounding
box call. However, this does fix the problem discovered in #523,
where calling canvas without modifying the y position ends
up putting the cursor at the absolute top of the page, outside
of the margins.

This is not an ideal fix, but it (mostly) preserves existing
behavior while providing sane behavior for an edge case.
@practicingruby
Copy link
Member

@JacobEvelyn: Can you try master and see if it fixes your issue?

@practicingruby
Copy link
Member

I believe this ought to solve your problem, but please leave a comment if it does not and I will re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants