简体   繁体   中英

jsreport doesn't render text

I have the following code , the result is a pdf which doesn't have any visible text in it. (I guess it renders it as the same color of the background even thoguh we change its colour in the inline style of the html)

var client = require("jsreport-client")('https://localhost:443');
var output = '<html><body><h1 style="color:blue;margin-left:30px;">This is a heading.</h1></body></html>';
           client.render({
               template: {  content: output }
           }, function(err, pdfResp) {
               pdfResp.pipe(res);
           });

When we copy and paste the content of the pdf into a text pad , the result is :

ihsish issi aa gheadinhadinge

Any idea how to solve it ?

I would guess phantomjs is missing some dependencies (fonts) required for rendering pdf. It runs for me if I spin up fresh centos VM on azure but I see people complaining sometimes required phantomjs dependencies are not preinstalled. Adding the missing package depends on your distribution

For example on ubuntu you may need to run:

sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev

on centos

sudo yum install freetype fontconfig

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM