openhtmltopdf css style problem in liferay portal - Stack Overflow

I am trying to export data from html to pdf on liferay portal 7.3.7 through openhtmltopdf 1.1.24 (tried

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744247174a4564991.html

相关推荐

  • openhtmltopdf css style problem in liferay portal - Stack Overflow

    I am trying to export data from html to pdf on liferay portal 7.3.7 through openhtmltopdf 1.1.24 (tried

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信