-
Notifications
You must be signed in to change notification settings - Fork 499
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
Bad page rendering: margins are off the page #1170
Comments
I have just checked with 4642974 -- it has no such a problem: |
And 1390e35 which was introduce by me :) causes the issue. But the changes there was only about default table alignment... |
So,
makes the test document crazy (as well as |
I tried the files you sent me and I don't get the result that you get. Are you sure you are synced with master? |
That tells me something is wrong with your master branch, because that is extremely unlikely. |
Yes, I have just double checked -- With the |
So I change the table_align from center to left and document renders OK. |
I would clone the repo again and start with a clean workspace. Something
got misconfigured.
…On Mon, Jul 22, 2019, 05:08 Maxim Kim ***@***.***> wrote:
So I change the table_align from center to left and document renders OK.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1170?email_source=notifications&email_token=AAATL535QVAM6PNJMO2RVTLQAWIK5A5CNFSM4IFXJJXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2PSSAA#issuecomment-513747200>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAATL55E3ANIY3F7DZOBL3DQAWIK5ANCNFSM4IFXJJXA>
.
|
It looks like the issue somehow connected to the fonts...
If I change noto serifs to open sans for Main section then rendering is OK. |
Just did it -- the same behaviour. |
And I have just tried bundled notoserif...subset font -- the same issue |
accidently closed, reopening |
And how do you make a document? Because without |
Another bundle with all fonts included: I have just tried 2 commands:
|
This weirdly strange combination of table alignment, diagrams and main font -- if I either change font to smth other than NotoSerif, or remove some tables from the document or will not include diagram rendering -- then document renders OK. |
BTW, if you open attached pdf from the original post and scroll it down from page 1 to the latest one you will see how left page margin changes. |
So I am pretty much sure this is reproducible: Inside the zip there is |
I was going to ask for a reproducible project. You beat me too it. In the meantime, if you could manage to reproduce it in a test case, that would be the quickest way to a solution. This strikes me as a bad interaction between the font library (ttfunk) and prawn-table. I can't really think off the top of my head how setting an alignment would mess up the margins otherwise. That's very bizarre. |
I've been able to reproduce the problem from your sample project. I'll see if I can determine the cause. |
Remember that the table of contents is rendered last. So what affects the last page also affects the table of contents. That's why the sections in between look fine. |
This is an extremely difficult behavior to track down. Almost any change to the document fixes it, so I can't manage to isolate it. It could be prawn-table. It could be prawn-svg. Or it could be something else. It doesn't have to do with the table alignment in the theme. If you set |
I've spent 3+ hours trying to narrow it down to the smallest document that ends up with this issue. Indeed, even the minor change to the simple text could make document OK again.
But if you will remove one of the diagrams -- document is OK again! I have also tried to insert another table instead of that removed diagram in case it is somehow connected to the length of the doc -- issue disappears then. Anyway, good things:
Bad things:
|
Agreed. Though I think that may have more to do with the y-offset changing than the diagram itself. I've been able to reproduce with no diagrams in the document. |
In fact, I can reproduce this with beta.1 by setting align=center on every table. So this issue is not new. It's just easier to trigger now. |
Btw, I can tell you that when it happens, the "x" on the bounding box goes negative. So we know why the text starts getting written off the page. We just don't know why the bounding box is being changed, or where. |
"there is no issue" was about "me have workaround" not that there is no issue at all :) |
And this is visible if you scroll the document downwards -- you will see that the left margin becomes less and less |
So I think this happens (but only in certain cases) when a table with center or right alignment gets split across pages. There must be a bug in prawn-table in how it handles the bounds that affects the page. A simple solution to this problem is to record the bounding box before the table and restore it afterwards. That way, whatever crazy thing prawn-table does, we just undo it ;) |
@habamax Yep, I know what you meant. I'm just very amazed that this also existed in beta.1 and we just didn't see it ;) But clearly it requires just the right document to reproduce. I've gotten the sample document down to about 15 pages. |
Good news! I can isolate at least one page in the 15 page document where I can turn the problem on and off. That should be enough for me to see what is different about Prawn's internal state at that point. All we need to do is figure out what state to reset and then we can at least fix the problem on our end. |
I finally found a workaround. The problem is caused by a bad interaction between a bounding box (for drawing) and the new page creation logic. Frankly, it's a bit of a mess in Prawn and not easily fixable. Suffice to say, it's not good to use a bounding box to restrict the width. It's better to use margins (i.e., indent), which sidesteps the issue entirely. I had found this out when doing the TOC, but forgot about that rule. Therefore, I will apply a patch to Prawn table that will use margin indenting instead of the bounding box to position the table. |
It's also unnecessary to use the bounding box (or margin) when the table has a width that matches the width of the page. So this issue shouldn't even come up unless you use autowidth (and the natural width is less than 100%) or an explicit width less than 100%. |
A fix is on the way. |
So I was all boastful that we had plenty of tests that this couldn't be a bug. Well, as it turns out, it was a bug that the tests missed. 🤯 But we've got a new test ready that will surely keep this bug out of our 🏠 now. |
Now I know a new word "boastful" :) I am happy you found out the root cause and come up with solution, can't wait to test it. PS |
…ins of subsequent pages
PR sent. See #1172.
Don't worry. The behavior of bounding_box at page boundaries still even confuses me. I honestly don't understand why Prawn can't handle that case correctly. But at least we know a perfectly good alternative that isn't affected by that problem. |
…ins of subsequent pages
Just tested it out -- looks good for me |
I now understand the root cause. We've already worked around it, but I want to document it here so the information isn't lost. If a bounding box is used around content that gets split across pages (which is what prawn-table does when position is set to center or right), and indent is used around subsequent content that also gets split across page, Prawn subtracts the indentation twice coming out of that function. That's why the margin kept getting smaller and smaller. So it's some sort of bad interaction between the bounding_box and indent functions. |
Yep, just confirmed it. bounding_box and indent just don't play together. There seems to be a flaw in Prawn's design here. It restores the padding to the wrong box, so when it removes the padding it goes negative. |
Here's the upstream issue. It doesn't affect us since we took another path, but I figured it was worth submitting the fix while it was fresh. prawnpdf/prawn-table#114 |
asciidoctor-pdf version: current master
test theme and test doc is in archive
testdoc.zip
result pdf with
mytest
themetestpage.pdf
With the default built in theme everything is OK though.
If I do minor changes to the test document -- margins are either ok or slighly wrong -- I couldn't figure out exactly what is the root cause of the issue.
The text was updated successfully, but these errors were encountered: