-1
我試圖創建按鈕使用DOMPDF保存後的PDF,但結果卻是一個錯誤:錯誤打印PDF與DOMPDF
Fatal error: Uncaught exception 'DOMPDF_Exception' with message
'Requested HTML document contains no data.' in
E:\xampp\htdocs\forum_seo\pages\posts\dompdf\include\frame_tree.cls.php:114
Stack trace: #0
E:\xampp\htdocs\forum_seo\pages\posts\dompdf\include\dompdf.cls.php(533):
Frame_Tree->build_tree() #1
E:\xampp\htdocs\forum_seo\pages\posts\dompdf\include\dompdf.cls.php(696):
DOMPDF->_process_html() #2
E:\xampp\htdocs\forum_seo\pages\posts\post_download.php(43):
DOMPDF->render() #3 {main} thrown in
E:\xampp\htdocs\forum_seo\pages\posts\dompdf\include\frame_tree.cls.php
on line 114
文件post_download.php
<html>
<head>
<meta charset="utf8" />
<link rel="stylesheet" type="text/css" href="../../css/style1.css"/>
</head>
<body>
<?php
require_once '../connect.php';
$sql_head_post="SELECT *,seo_members.id as idp ,seo_articles.id as id_post,seo_articles.num_like as postlike,seo_members.num_like as userlike,DATE_FORMAT(dateattend,'%d-%m-%Y') as date_join, DATE_FORMAT(date_post, '%d-%m-%Y') AS _date, DATE_FORMAT(date_post, '%h:%i %p') AS _time
FROM seo_articles
INNER JOIN seo_subcate ON seo_articles.id_cate = seo_subcate.id
INNER JOIN seo_members ON seo_articles.id_user = seo_members.id
WHERE seo_articles.id =$_GET[dl_post]
LIMIT 1";
$q_post_det= mysqli_query($con,$sql_head_post);
$r_post_det=mysqli_fetch_array($q_post_det);
?>
<div class='title' style='display: block;'>
<div style='float:left;width:1000px;text-overflow: ellipsis;word-wrap: break-word;' >
<b class='title-post'><?php echo "$r_post_det[article]";?></b>
<p>cate: <?php echo "$r_post_det[subcate], post by $r_post_det[username], $r_post_det[_date], $r_post_det[_time]";?></p>
</div>
</div>
<div class='detaild' >
<hr style='clear:both; border:1px solid #555;border-style: dashed' />
<p><?php echo "$r_post_det[content]";?></p>
</div>
</body>
</html>
<?php
require_once("dompdf/dompdf_config.inc.php");
ob_start();
$content = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($content);
$dompdf->render();
$dompdf->stream("$r_post_det[article].pdf");
?>