HTML到PDF的node-wkhtmltopdf在Digital Ocean Droplet服务器上崩溃

时间:2018-10-12 14:37:11

标签: node.js ubuntu npm digital-ocean wkhtmltopdf

我正在尝试从html生成pdf文件,并且想知道最好的方法。我尝试了html-pdf,pdf-puppeteer,node-wkhtmltopdf。

使用Ubuntu映像在Digital Ocean Droplet上使用0给出错误时,前2个使服务器崩溃。它们可以在我的计算机(MAC OS)上正常工作,但是无法到达服务器上的任何位置。当我尝试node-wkhtmltopdf时,它看起来很有希望:

var wkhtmltopdf = require('wkhtmltopdf');

wkhtmltopdf(html).pipe(res);

它崩溃并显示错误消息: >

  

错误:qt.qpa.screen:QXcbConnection:无法连接到显示器

     

无法连接到任何X显示器

我想知道使用Digital Ocean Droplet创建pdf的最佳方法。

1 个答案:

答案 0 :(得分:0)

找到解决方案后,使用ubuntu上的“ apt-get install”安装的版本的qt损坏了。

因此,我从git存储库安装了wkhtmltopdf,并且运行良好。

https://github.com/wkhtmltopdf/wkhtmltopdf/releases/