简体   繁体   English

jsreport不呈现文本

[英]jsreport doesn't render text

I have the following code , the result is a pdf which doesn't have any visible text in it. 我有以下代码,结果是pdf,其中没有任何可见的文本。 (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) (我猜它会将其呈现为与背景相同的颜色,即使我们以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 : 当我们将pdf的内容复制并粘贴到文本板中时,结果是:

ihsish issi aa gheadinhadinge ihsish issi aa gheadinhadinge

Any idea how to solve it ? 知道如何解决吗?

I would guess phantomjs is missing some dependencies (fonts) required for rendering pdf. 我猜想phantomjs缺少呈现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. 如果我在Azure上启动新的centos VM,它会为我运行,但是我看到人们抱怨有时未预先安装必需的phantomjs依赖项。 Adding the missing package depends on your distribution 添加缺少的软件包取决于您的分发

For example on ubuntu you may need to run: 例如,在ubuntu上,您可能需要运行:

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

on centos 在centos上

sudo yum install freetype fontconfig

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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