-
Notifications
You must be signed in to change notification settings - Fork 364
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
com.openhtmltopdf.render.ContentLimitContainer failing in updateTop method in some cases. #553
Comments
hi @adilxoxo , what do you mean by "it fail" (if there are no exception)? Do you have an example ? |
I can not tell certain example but I would like to know in which cases it might fail. Just give me clear idea or guide me to doc regarding same. Because this is happening only for some particular reports. This is log generated my app. I will share stack trace soon. 2020.09.14 14:33:24 diff: 0 Thread: 3b Session: 0 Event: ERROR Source: AbstractPDFReport::printPDFReport[150] > |
Please find stack trace below for same issue. 2020.09.15 15:48:52 diff: 0 Thread: 2f Session: 0 Event: ERROR Source: AbstractPDFReport::printPDFReport[157] > null |
thank you, the NullPointerException is the one i expected, as in the code: openhtmltopdf/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/ContentLimitContainer.java Line 69 in 8be80a4
So it seems Could you provide a minimal reproducer? Unfortunately I don't think I'm able to debug without it. |
What kind of data do you need ? We use free marker to generate html string from template then by using jsoup we convert that data into w3c doc. Data passed to free marker is map and json. |
The html template that generates this error. You should try to remove as
much as possible html/text/css.
…On Tue, Sep 15, 2020 at 1:39 PM Adil ***@***.***> wrote:
What kind of data do you need ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#553 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADZTYV7GNNVEH6DVEZQF7LSF5G7NANCNFSM4RLQ75VQ>
.
|
Code snippet :
PFA for html template causing issue. |
I did a try with the version 1.0.4 using the following code: try (OutputStream os = new FileOutputStream("test.pdf")) {
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode();
builder.withW3cDocument(W3CDom.convert(Jsoup.parse(new File("template.html"), "UTF-8", "")), "");
builder.toStream(os);
builder.run();
} and it generate the following pdf, without any issues: |
Can you please try adding fonts to it.
After looking at your code I tried removing fonts from builder and found that after adding arialuni font to builder is causing issue. I am using version 1.0.3. |
Using your template.html with the provided fonts work as expected, with both version 1.0.3 and 1.0.4. Full code:
Maybe it's some data that you have removed from the |
Actually I might be able to fix it as I was ignoring warning for missing ; in style tag. After adding ; to ** box-sizing: border-box** now its working. Let me run more scenarios. If issue comes up again will ping you. Thank you for the help by the way @syjer |
Hi, I am able to reproduce this issue again. Please try attached template file. This issue occurs when we add empty lines to some data... in my case empty line looks like Also I found this issue #399 which seems similar to mine as it is occurring while page break inside table. |
I tried debugging code in library and at one point it returns null with input values as below, pageNo ==== 1 Also I am able to reslove this issue by replacing Does order of applying css matters?? also the table border is not proper at page break as shown in below image, |
Hi @adilxoxo, In answer to your original question, the method is designed to reserve space as required for paginated table header and footer on each page. I'll try to have a look over the weekend. |
Based on your debugging (thanks), I was able to condense the failing test to: <html>
<body>
<div style="page-break-before: always;"></div>
<table style="margin-top: -20px; -fs-table-paginate: paginate;">
<tr><td>Row 1</td></tr>
</table>
</body>
</html> It doesn't like negative margins that push paginated tables back to the previous page. This is the offending CSS in your template: .topMargin table{
margin-top:-10px !important;
margin-bottom:20px !important;
max-width: 630px;
} If you change this I'll see if I can fix this bug now by factoring in the margin to the initial page calculation. |
Thanks for pointing out the fix. Will do above change to my template. |
…ccount for negative margins.
Hey @danfickle, Hope you are doing well. I have another use case in which if |
Hi @adilxoxo, sorry for missing this, but do you know if this is still a problem or has my fix solved it? |
I am not able to get this issue as it is happening in one particular setup. It is working on other setups. Can you please help me to understand this methods purpose. So I can understand where I need to check.
It is failing with no exception message.
#Class Name::com.openhtmltopdf.render.ContentLimitContainer:: Method Name::updateTop:: Line Number::69#
The text was updated successfully, but these errors were encountered: