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

Getting a nullptr exception, reproduction case included #594

Closed
ThomHurks opened this issue Nov 8, 2020 · 5 comments
Closed

Getting a nullptr exception, reproduction case included #594

ThomHurks opened this issue Nov 8, 2020 · 5 comments

Comments

@ThomHurks
Copy link

ThomHurks commented Nov 8, 2020

Hi!

First of all, it's been great using your library. Good work!

I noticed that with certain content (part of the content I include in the HTML is generated) I'm getting a crash when the PDF is generated. I managed to reduce the problem to a case that is pretty minimal I think;
https://github.com/ThomHurks/openhtmltopdfcrash

The nullpointer exception happens when OpenHtmlToPdf calls org.apache.pdfbox.cos.COSArray.add(COSArray.java:62)

If you need any help in figuring out the problem, please let me know!

Full stacktrace:

com.openhtmltopdf.general INFO:: Using fast-mode renderer. Prepare to fly.


java.lang.NullPointerException
	at org.apache.pdfbox.cos.COSArray.add(COSArray.java:62)
	at com.openhtmltopdf.pdfboxout.PdfBoxAccessibilityHelper.finishNumberTree(PdfBoxAccessibilityHelper.java:847)
	at com.openhtmltopdf.pdfboxout.PdfBoxFastOutputDevice.finish(PdfBoxFastOutputDevice.java:911)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.writePDFFast(PdfBoxRenderer.java:670)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPdfFast(PdfBoxRenderer.java:559)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:477)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:414)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:396)
	at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:42)
	at com.example.openhtmltopdfcrash.OpenHtmlToPdfCrash.reproduce(OpenHtmlToPdfCrash.java:34)
@syjer
Copy link
Contributor

syjer commented Nov 12, 2020

hi @ThomHurks , thank you for providing a minimal test case.

It seems to be the same issue as #527 and #401

@danfickle
Copy link
Owner

@ThomHurks, @syjer

Thanks for the test case! After much debugging (at least six hours!), it turns out the core problem is that content (the last table row specifically) is being repeated where it shouldn't be in the page margins (not visibly) (and the accessibility code doesn't act well on this bug). This is similar to #458.

I was able to finally reproduce in a smaller sample and I have committed this as a (failing currently) test case. I will continue working on this to fix it.

Thanks again.

@ThomHurks
Copy link
Author

Thanks a lot for the help, @danfickle! That sounds like a die-hard debugging session. Great work you're doing here 👍

@danfickle danfickle self-assigned this Nov 20, 2020
danfickle added a commit that referenced this issue Nov 27, 2020
This fixes repeating content in page margins when line-height is other than one. It also fixes the PDF UA crash caused by the repeating content.

However, it is a behavior changing fix. Documents with text split over two pages (usually undesired) will now get a forced page break before the split text.
@danfickle
Copy link
Owner

Hi @ThomHurks,

I have added PR #610 that fixes this problem. However, I just need to create some more tests before merging and then I can do a release finally.

danfickle added a commit that referenced this issue Nov 28, 2020
With changes to get it working and test proof.
@ThomHurks
Copy link
Author

@danfickle Thanks a lot! Amazing job 👌

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

No branches or pull requests

3 participants