jsreport doesn't render text

439 Views Asked by At

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 ?

1

There are 1 best solutions below

1
On

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