我在开始使用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字节。
我不明白我在这里做错了什么。有什么想法吗??
http://www.princexml.com/forum/topic/1292/prince-on-os-x-mamp