Getting a nullptr exception, reproduction case included
ThomHurks opened this issue ยท 5 comments
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)
hi @ThomHurks , thank you for providing a minimal test case.
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.
Thanks a lot for the help, @danfickle! That sounds like a die-hard debugging session. Great work you're doing here ๐
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 Thanks a lot! Amazing job ๐