在使用xamp本地服务器的Windows上,我按照pdf generator from html进行操作 第1步& 2(wkhtmltopdf http://www.test.com test.pdf)没问题,但第3步
3. In php you should execute the tool using shell_exec:
shell_exec("/usr/local/bin/wkhtmltopdf-i386 http://test.com test.pdf");
//for Linux 32 bits operating system
//for Linux 64 bits operating system use wkhtmltopdf-amd64
//for windows just put the path of the exe file.
$allfile = file_get_contents("test.pdf");
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($allfile));
header('Content-Disposition: inline; filename="test.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
没有做任何事情...... :(
我安装在电子驱动器上并使用:
exec("e:\wkhtmltopdf\wkhtmltopdf.exe http://www.google.com/ test.pdf");
实际上我正确创建PDF但不向浏览器发送输出.. 知道我错过了什么......?
答案 0 :(得分:0)
我猜,但问题可能是文件位置。 file_get_contents实际上是否找到了文件?
我不太确定在exec期间生成pdf文件的位置,尝试使用输出pdf位置和file_get_contents位置的完整路径,默认情况下它们可能不正确。 Maby甚至检查文件是否存在以及它们都使用了什么文件夹(我不记得如何在PHP中执行此操作:))