NPE on PDF report of Test record
Activity
Carlos Ruiz February 12, 2022 at 9:47 AM
Thanks - I repeated the test - it seems is more specific.
The NPE is shown when the HTML text has a list of at least two entries
For example, this Description throws NPE:

Heng Sin Low February 12, 2022 at 7:43 AM
Hi ,
I tested the isHTML fix and it works fine for me without the getContainer() change (Print Sales Order PDF with html description text).
Regards,
Low
Carlos Ruiz February 11, 2022 at 9:28 PM
Hi - can you please take a look to the pull request 1180 ?
The history behind this:
I noticed that because of the <html> tag is now removed from Strings saved in the database
The method HTMLElement.isHTML was trusting that iDempiere Strings have that tag, that means after IDEMPIERE - 3980 any HTML string is being rendered (printed) as plain text in PDF files
I did the test creating a Sales Order and adding HTML content in the Description, and effectively is being printed as plain text
The exception is in the Test table which has an old record with CharacterData starting with <html>
If this record is edited and saved back to the database, the <html> tag is removed and then the print format Test Form doesn’t throw NPE, but it prints the CharacterData just as plain text
To solve that, I changed the HTMLElement.isHTML to recognize patterns of HTML
And then, noticed the problem is not just with Test print format, but with any print format that tries to print HTML content (the Sales Order Description starting to throw NPE too)
Here after some debugging noticed that the javax.swing code that renders the PDF is getting a null container from our HTMLRenderer class
So, I tried simply to add a Container - without any configuration - in HTMLRenderer and return it in the method getContainer, and the NPE is gone and everything is printed correctly
However, I’m not sure that simply adding that Container is the right fix (I have no experience with the PDF libraries)
Regards,
Carlos Ruiz
Test case:
As System Administrator
Open the Test window
http://demo.globalqss.com/webui/index.zul?Action=Zoom&AD_Table_ID=135&Record_ID=103
Click the Report button and OK
Error: org.adempiere.exceptions.AdempiereException: org.adempiere.exceptions.AdempiereException: java.lang.NullPointerException
Error: Unknown exception: java.lang.NullPointerException.
Console shows something like: