-
Notifications
You must be signed in to change notification settings - Fork 610
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
NPE in PdfContentByte ... table cannot be drawn when exceeding space and uses background color ... now with test #370
Comments
OK, I have a test class for this error, maybe this helps ...
|
as I said, in openPDF 1.3.11 this works, with 1.3.12 up to 1.3.17, the NPE occurs.
|
Thanks for reporting this bug. This seems to be the relevant code where the NullpointerException occurs: This seems to be the relevant pull request: Perhaps we can just add some checks to protect this method from NPExceptions? |
Yes! @andreasrosdal it works, thank you! |
OpenPDF 1.3.18 has been released today, with this fix included. |
Hello there!
I use several tables in my created pdf document to set the text layout.
At some step I use up to three tables (with background), if the next table would cause a page break a NullPointerException occurs.
This NPE occurs at
Caused by: com.lowagie.text.DocumentException: java.lang.NullPointerException at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:770) at com.lowagie.text.Document.add(Document.java:293) at de.msg.vorsorge.all.pdf.PdfCTabelle.go(PdfCTabelle.java:337) ... 10 more Caused by: java.lang.NullPointerException at com.lowagie.text.pdf.PdfContentByte.setGState(PdfContentByte.java:3042) at com.lowagie.text.pdf.PdfContentByte.saveColorFill(PdfContentByte.java:2350) at com.lowagie.text.pdf.PdfContentByte.setRGBColorFill(PdfContentByte.java:2233) at com.lowagie.text.pdf.PdfContentByte.setColorFill(PdfContentByte.java:2343) at com.lowagie.text.pdf.PdfContentByte.rectangle(PdfContentByte.java:1029) at com.lowagie.text.pdf.PdfDocument.renderCells(PdfDocument.java:3037) at com.lowagie.text.pdf.PdfDocument.addPdfTable(PdfDocument.java:2694) at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:729) ... 12 more
In this context a PdfContentByte(null) is created in PdfDocument.addPdfTable.
Then, in PdfContentByte.setGState, the (not initalized) writer is used ... NPE occurs.
It occurs as I see now, when a page break occurs and the table uses a background color (lightgrey).
I use .setTableFitsPage(true), but when using .setTableFitsPage(false), there is the NPE as well.
As long as the the table with background color does not exceed the remaining space (or no background color ist used), it is drawn, too.
So the NPE occurs when exceeding the remaining page size and when background color is used.
NOTE: with openPdf 1.3.11 my code worked and no NPE occured. Is it a bug since 1.3.12 or a bug or too-old-fashioned code in my project?
The text was updated successfully, but these errors were encountered: