我在使用Princexml时遇到了问题。我正在尝试创建我的第一个测试PDF。
这是我的代码:
require_once dirname(__FILE__).'/prince.php';
$prince = new Prince('/usr/local/bin/prince');
$prince->setHTML(1);
$prince->setLog("/log.txt");
$prince->setPDFTitle("Test File");
$html = file_get_contents(dirname(__FILE__)."/out/test.html");
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="foo.pdf"');
$ret = $prince->convert_string_to_passthru($html);
test.html
文件包含以下内容:
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>hello world!</h1>
</body>
</html>
PDF正在加载(如果我使用'inline'而不是附件),但它是一个空白文档。当我使用'attachment'时,文件的大小为0字节。
我无法弄清楚我在这里做错了什么。任何想法??
答案 0 :(得分:0)
我找到了答案。这显然是MAMP的一个问题:
http://www.princexml.com/forum/topic/1292/prince-on-os-x-mamp