【发布时间】:2014-01-18 21:35:42
【问题描述】:
使用 WordPress 3.8,我包含了 dompdf 库来生成我的网站的投资组合,我尝试了不同的方式,但没有得到解决方案。这是我尝试过的代码。
<?php
require_once ('dompdf/dompdf_config.inc.php');
$id="80";
$post = get_page($id);
$contents = apply_filters('the_content', $post->post_content);
$html =
'<html><body>'.
'<p>Put your html here, or generate it with your favourite '.
'templating system.</p>';
$html.= $contents;
$html .='</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("Dotcom Portfolio.pdf");
}
?>
不是:当我回显 $contents 变量时,它会打印存储在其中的数据。就像
$post = get_page($id);
$contents = apply_filters('the_content', $post->post_content);
echo $contents;
die();
但不存储在 $html 变量中转换为 PDF。
提前致谢。
【问题讨论】:
-
你能告诉我
$content变量包含哪些数据吗? -
它包含整个数据,动态WordPress页面包含的意思是页面的所有内容
-
是的,但我需要看看它的 html 是什么样子。所以请死
$contents并将它的值复制粘贴到这里。 -
太长的结果无法在评论中显示,当我打印 $content 时,它包含图片和图表以及文本数据。
-
当您尝试创建 PDF 时会向浏览器发送什么?如果你回显
$html变量,你会得到什么?