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

PDF renderer doesn't work if the HTML has CDATA sections. #16

Closed
joaomarcusc opened this issue Mar 28, 2016 · 1 comment
Closed

PDF renderer doesn't work if the HTML has CDATA sections. #16

joaomarcusc opened this issue Mar 28, 2016 · 1 comment

Comments

@joaomarcusc
Copy link
Contributor

Whenever I try to convert an HTML with CDATA sections to PDF, I get a NullPointerException back. If one tries to execute the following snippet:

    PdfRendererBuilder builder = new PdfRendererBuilder();
    builder.toStream(outputStream);
    builder.withHtmlContent("<html><body><div><![CDATA[test]]></div></body></html>", "");
    builder.run();

The following error will occur

Exception in thread "main" java.lang.NullPointerException
    at com.openhtmltopdf.layout.BoxBuilder.doBidi(BoxBuilder.java:1250)
    at com.openhtmltopdf.layout.BoxBuilder.createChildren(BoxBuilder.java:1207)
    at com.openhtmltopdf.layout.BoxBuilder.createChildren(BoxBuilder.java:132)
    at com.openhtmltopdf.render.BlockBox.ensureChildren(BlockBox.java:970)
    at com.openhtmltopdf.layout.BoxBuilder.createChildren(BoxBuilder.java:1199)
    at com.openhtmltopdf.layout.BoxBuilder.createChildren(BoxBuilder.java:132)
    at com.openhtmltopdf.render.BlockBox.ensureChildren(BlockBox.java:970)

This happens because the paragraph splitter doesn't recognize CDATA sections as text. The pull request #15 fixes this issue.

@danfickle
Copy link
Owner

Thanks again @HiddenDog

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

No branches or pull requests

2 participants