我一直在使用wkthmltopdf在我的linux web服务器上即时地将html转换成pdf文档。该程序最初需要X11或类似的X服务器才能正常运行,但通过开发人员多次请求在没有图形用户界面的服务器上运行,我非常确定它在static version中运行虚拟X服务器。我一直在使用这个程序的静态(独立)版本,它工作得很好!我会将可执行文件放在一个文件夹中,然后运行:
./wkhtmltopdf file1.html file2.pdf
但是,我想在整个系统范围内安装此程序。我使用的是apt-get install wkhtmltopdf
(昨天才安装的),因为我运行的是64位系统,所以我也需要apt-get install ia32-libs
。安装后,我可以找到这样的版本:
wkhtmltopdf --version
输出:
Name:
wkhtmltopdf 0.9.9
License:
Copyright (C) 2008,2009 Wkhtmltopdf Authors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO
WARRANTY, to the extent permitted by law.
Authors:
Written by Jakob Truelsen. Patches by Mário Silva, Benoit Garret and Emmanuel
Bouthenot.
现在,当我尝试运行通过aptitude安装的程序时,我得到了以下错误:
wkhtmltopdf: cannot connect to X server
有人知道我怎么解决这个问题吗?我猜这个版本缺少虚拟X服务器之类的东西。
发布于 2012-03-08 00:47:18
我刚刚发现,我可以简单地将静态可执行文件移动到/usr/bin/
目录,然后从任何地方执行它。
发布于 2012-11-28 20:13:00
这为我解决了这个问题:
sudo apt-get install xvfb
xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf file1.html file2.pdf
发布于 2014-11-14 20:28:25
就这么做了:
1-下载wkhtmltopdf依赖项
# apt-get install wkhtmltopdf
2-从源代码下载
# wget http://downloads.sourceforge.net/project/wkhtmltopdf/xxx.deb
# dpkg -i xxx.deb
3-尝试
# wkhtmltopdf http://google.com google.pdf
它工作正常
它起作用了!
https://stackoverflow.com/questions/9604625
复制相似问题