我在开始使用 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 字节。
我无法弄清楚我在这里做错了什么。有任何想法吗??