【问题标题】:HTML to PDF with node-wkhtmltopdf crashing on a Digital Ocean Droplet serverHTML to PDF with node-wkhtmltopdf 在 Digital Ocean Droplet 服务器上崩溃
【发布时间】:2018-10-19 22:56:16
【问题描述】:

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

前 2 个在使用 Ubuntu 映像的 Digital Ocean Droplet 上给出 0 个错误时导致服务器崩溃。它们在我的计算机(MAC OS)上运行良好,但无法在服务器上运行。当我尝试 node-wkhtmltopdf 时,看起来很有希望:

var wkhtmltopdf = require('wkhtmltopdf');

wkhtmltopdf(html).pipe(res);

它崩溃并给出错误消息: >

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

无法连接到任何 X 显示器

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

【问题讨论】:

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


    【解决方案1】:

    找到解决方案,在 ubuntu 上使用 'apt-get install' 安装的版本的 qt 已损坏。

    所以,我从 git 存储库安装了 wkhtmltopdf,它运行良好。

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

    【讨论】:

      猜你喜欢
      • 2015-11-15
      • 2023-02-04
      • 1970-01-01
      • 2018-03-06
      • 1970-01-01
      • 2020-10-02
      • 2017-02-25
      • 2018-09-22
      • 2020-07-24
      相关资源
      最近更新 更多