问题描述
1) 我将wkhtmltopdf-i386"上传到我的服务器中名为/pdf"的文件夹
1) I uploaded"wkhtmltopdf-i386" to my server in a folder named "/pdf"
2) 我在同一个文件夹中上传了 php 集成脚本,并将其命名为wkhtmltopdf.php"(http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp)
2) I uploaded the php integration script, in the same folder, and named it "wkhtmltopdf.php" (http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp)
3) 我在同一个文件夹中上传了一个名为usage.php"的文件,其中包含:
3) I uploaded a file that I named "usage.php", in the same folder, containing :
<?php
require_once('wkhtmltopdf.php');
$pdf=new WKPDF();
$pdf->set_html('Hello world!');
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');
?>
4) 我创建了一个具有 777 权限(全部)的/tmp 文件夹.
4) I created a /tmp folder with 777 permissions (all).
当我加载usage.php时,出现以下错误:
When I load usage.php, I get the following error:
"Fatal error: Uncaught exception 'Exception' with message 'WKPDF didn't return any data. <pre></pre>' in /home/***/public_html/dev/pdf/wkhtmltopdf.php:205 Stack trace: #0 /home/***/public_html/dev/pdf/usage2.php(5): WKPDF->render() #1 {main} thrown in /home/***/public_html/dev/pdf/wkhtmltopdf.php on line 205"
为了您的信息,每次我加载 usage.php 时,都会在/tmp 文件夹中呈现一个 html 页面.
For your info, a html page is rendered in /tmp folder each time I load usage.php.
你知道如何解决我的问题吗?
Do you have any clue on how to solve my issue?
谢谢
推荐答案
您是否尝试查看 wkhtmltopdf.php
的内部?
Have you tried looking inside your wkhtmltopdf.php
?
确保这一行:
/**
* path to executable
*/
protected $_bin = '/usr/bin/wkhtmltopdf';
不是 /usr/bin/wkhtmltopdf
而是您放置 wkhtmltopdf-i386
的绝对路径.
is not /usr/bin/wkhtmltopdf
but is the absolute path where you put your wkhtmltopdf-i386
.
就您而言,可能是 /pdf/wkhtmltopdf-i386
.
这篇关于wkhtmltopdf 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!