0

我在开始使用 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 正在加载(如果我使用“内联”而不是附件),但它是一个空白文档。当我使用“附件”时,文件大小为 0 字节。

我无法弄清楚我在这里做错了什么。有任何想法吗??

4

1 回答 1

0

我找到了答案。这显然是 MAMP 的一个问题:

http://www.princexml.com/forum/topic/1292/prince-on-os-x-mamp

于 2014-04-24T20:32:15.747 回答