admin管理员组

文章数量:1405160

I am trying to export data from html to pdf on liferay portal 7.3.7 through openhtmltopdf 1.1.24 (tried 1.0.10 too). Sample HTML:

<html>
<head>
<style>
* { 
    font-family: 'Verdana';
}
</style>
</head>
<body>
    <h1 id="title1">Main</h1>
    <p>text under main</p>
    <h2 id="subtitle1">Sub 1</h2>
    <p>next text</p>
    <h2 id="subtitle2">Sub 2</h2>
    <p>more text</p>
</body>
</html>

and code, that is generating pdf:

    PdfRendererBuilder builder = new PdfRendererBuilder();
    FSSupplier<InputStream> verdana = new FSSupplier<InputStream>() {
    @Override
        public InputStream supply() {
            return PrintArticleToPDFAction.class.getResourceAsStream("/fonts/verdana.ttf"); //need other font for special characters and PDF/A2
        }
    };
    builder.useFont(verdana, "Verdana");
    builder.toStream(outputStream);
    InputStreamReader isr = new InputStreamReader(PrintArticleToPDFAction.class.getResourceAsStream("/test/test2.html"), "UTF-8"); // I have my html code in file for easier edit
    String finalHtml = new BufferedReader(isr).lines().collect(Collectors.joining("\n"));
    _log.info("!!!!!!!!!!!!" + finalHtml);
    builder.withHtmlContent(finalHtml, null);
    builder.run();

and result is this

When I try it in openhtmltopdf sandbox, it is working okay. Any suggestions, what can be problem here? Maybe something in liferay portal?

THX

本文标签: openhtmltopdf css style problem in liferay portalStack Overflow