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

nbsp and other HTML entities cause the parser to stop rendering with an INFO only #71

Closed
Jo3McCarthy opened this issue Feb 16, 2017 · 6 comments

Comments

@Jo3McCarthy
Copy link

Hi, All;

Running the minimal use example against some markup will not complete successfully. The parser will occasionally notify, but invariably fail on HTML entities.

One example:
... 
Causes this:

com.openhtmltopdf.load INFO:: Reference to undefined entity: nbsp

And, although it is only an INFO the parsing stops and no further content is rendered. Has anyone encountered and/or fixed this?

Thanks,

Jo3

@danfickle
Copy link
Owner

Currently HTML entities are not supported by default. Only XML entities. Agreed, this needs to be fixed so please leave issue open. In the mean time, you could use numeric character entities. Or you could try the jsoup parser.

@davidbio
Copy link

@Jo3McCarthy
As a temporary workaround and if you can modify or extend the source HTML:
You can add your own entities in the DOCTYPE tag and the library will convert them accordingly:

<!DOCTYPE definition [
<!ENTITY reg "&#174;">
<!ENTITY diams "&#9830;">
]>
<definition name="dashboard" extends="base.definition">
    <put-attribute name="title" value="Dashboard - CMS &diams; &reg; Galactic NetOne" />
    <put-attribute name="body" value="/WEB-INF/views/dashboard.jsp" />
</definition>

Inspired by: http://stackoverflow.com/questions/15858914/entity-was-referenced-but-not-declared
Lists of entities you may want to include: https://www.w3.org/TR/xhtml1/dtds.html#h-A2

@rahulgurnani
Copy link

rahulgurnani commented Jan 3, 2019

Apparently, replacing by "nbsp" by "#160" doesn't help or adding nbsp entity doesn't help

@danfickle
Copy link
Owner

See documentation on doctype here:
https://github.com/danfickle/openhtmltopdf/blob/open-dev-v1/openhtmltopdf-examples/src/main/resources/documentation/documentation.md

This documentation needs to be moved to the wiki.

@rahulgurnani
Copy link

Thanks for the quick response.

@danfickle
Copy link
Owner

Finally added section in integration guide on character entities.

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

4 participants