以下是我使用dompdf显示pdf的代码,但错误无法加载pdf PDF.js v0.8.787(build:58407cf) 消息:InvalidPDFException
表名是acad_act,数据库名是pbas_db。数据库连接的详细信息存储在db_connect.php中。任何帮助都会很明显
<?php
include('db_connect.php');
require 'dompdf/dompdf_config.inc.php';
$sqlinv="SELECT * FROM acad_act";
$res_inv = mysql_query($sqlinv) or die(mysql_error());
while ($sql3=mysql_fetch_array($res_inv)) {
$inv_id = $sql3['User_id'];
$date = $sql3['Year'];
$cname = $sql3['Gen_Info_AQ'];
$subtotal = $sql3['Gen_Info_NOC'];
$disc = $sql3['Gen_Info_Place'];
$subtotal2 = $sql3['Gen_Info_Duration'];
$tax = $sql3['Gen_Info_SA'];
$gtotal = $sql3['Gen_Info_Aqyear'];
}
$dompdf= new DOMPDF();
$html .="<html>
<head>
<style>
body {
font-family: arial;
font-size: 13px;
}
table {
width: 100%;
border-collapse: collapse;
}
th {
font-weight: bold;
font-size: 14px;
border: 1px solid #333333;
}
tr {
width: 100%;
}
td {
border: 1px solid #333333;
text-align: center;
padding: 10px;
font-weight: normal!important;
}
</style>
</head><body>";
$html .="
<table>
<thead>
<tr>
<th class=''>Sr.</th>
<th class=''>Particulars</th>
<th class=''>Size</th>
<th class=''>Quantity / Insertion</th>
<th class=''>Rate</th>
<th class=''>Amount</th>
<th class=''>Amount 2</th>
<th class=''>Amount 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>" . $inv_id . "</td>
<td>" . $date . "</td>
<td>" . $cname . "</td>
<td>" . $subtotal . "</td>
<td>" . $disc . "</td>
<td>" . $subtotal2 . "</td>
<td>" . $tax . "</td>
<td>" . $gtotal . "</td>
</tr>
</tbody>
</table>
</body>
</html>";
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
exit(0);
?>
答案 0 :(得分:1)
异常是由于浏览器中安装了pdf.js插件。 pdfjs不显示错误,而是显示不显示错误的异常。只需删除pdfjs插件,就可以看到所需的错误。