Php FPDF错误:某些数据已被输出。Can';不要发送PDF文件
我正在使用FPDF库生成PDF文档,但出现错误“一些数据已经输出,无法发送PDF”Php FPDF错误:某些数据已被输出。Can';不要发送PDF文件,php,fpdf,Php,Fpdf,我正在使用FPDF库生成PDF文档,但出现错误“一些数据已经输出,无法发送PDF” <?php function fetch_data() { //užklausa include('database_connection.php'); $query = "SELECT * FROM mvap.daiktas"; $statement = $connect->prepare($query); $statement->execute();
<?php
function fetch_data()
{
//užklausa
include('database_connection.php');
$query = "SELECT * FROM mvap.daiktas";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$id = 1;
foreach($result as $row)
{
$pavadinimas = $row['daiktoPavadinimas'];
$inventorinis = $row['inventorinisNr'];
}
$data = '2020-01-25';
$html = '
<body>
<style>
th {font-weight: bold; font-family: };
tr {font-weight: normal};
</style>
<table border="1" cellpadding="4" cellspacing="0" style="text-align: center">
<tr>
<th width="30px" height="5">Eil. Nr.</th>
<th width="130px" height="5">Materialinės vertybės pavadinimas</th>
<th width="80px" height="5">Inventorinis numeris</th>
<th width="100px" height="5">Gamyklinis numeris</th>
<th width="70" height="5">Gavimo data</th>
<th width="65" height="5">Gavėjo parašas</th>
<th width="70" height="5">Grąžinimo data</th>
<th width="80" height="5">Grąžinančio asmens parašas</th>
<th width="70" height="5">Priimančio asmens parašas</th>
<th width="80" height="5">Pastabos</th>
</tr>
<tr>
<td>'. $id .'</td>
<td>'. $pavadinimas .'</td>
<td>'. $inventorinis .'</td>
<td>-</td>
<td>'. $data .'</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</table>
</body>
';
return $html;
}
if(isset($_POST['submit1']))
{
require('libs/TCPDF/tcpdf_import.php');
$obj_pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle("Apskaitos kortelė");
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('dejavuserif');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('dejavuserif', '', 10);
$obj_pdf->AddPage();
$obj_pdf->Cell(0,6,'ĮMONĖ',0,0,'C');
$obj_pdf->Ln();
$obj_pdf->SetLineWidth(0.5);
$obj_pdf->Line(5, 15, 297-5, 15);
$obj_pdf->Ln();
$obj_pdf->SetFontSize(12);
$obj_pdf->Cell(0,20,'KOMPIUTERINĖS TECHNIKOS, RYŠIO PRIEMONIŲ IR PROGRAMINĖS ĮRANGOS APSKAITOS KORTELĖ',0,0,'C');
$obj_pdf->Ln();
$obj_pdf->SetFontSize(10);
$obj_pdf->Cell(20, 40, 'Valdybos, skyriaus pavadinimas' , 0, false, 'L', 0, '', 0, false, 'T', 'M');
$obj_pdf->Cell(230, 40, 'SKOV NKC', 0, false, 'C', 0, '', 0, false, 'T', 'M');
$obj_pdf->Line(10, 65, 297-100, 65);
$obj_pdf->Ln(0);
$obj_pdf->Cell(20, 55, 'Turto buvimo vieta, kab. Nr.' , 0, false, 'L', 0, '', 0, false, 'T', 'M');
$obj_pdf->Cell(230, 55, 'Kabinetas', 0, false, 'C', 0, '', 0, false, 'T', 'M');
$obj_pdf->Line(10, 72, 297-100, 72);
$obj_pdf->Ln(0);
$obj_pdf->Cell(20, 70, 'Atsakingo žmogaus vardas, pavardė' , 0, false, 'L', 0, '', 0, false, 'T', 'M');
$obj_pdf->Cell(230, 70, 'Vardenis Pavardenis', 0, false, 'C', 0, '', 0, false, 'T', 'M');
$obj_pdf->Line(10, 80, 297-100, 80);
$content = '';
$content .= fetch_data();
$obj_pdf->SetXY(5, 90);
$obj_pdf->writeHTML($content);
$obj_pdf->Output('doc.pdf', 'I');
}
?>
解决了我的问题。我不会删除我的主题。希望这对某人有帮助。
通过将此php代码发布到另一个空白php文件并从另一个文件调用该文件来解决此问题。现在它可以正常工作了。解决了我的问题。我不会删除我的主题。希望这对某人有帮助。
通过将此php代码发布到另一个空白php文件并从另一个文件调用该文件来解决此问题。现在它可以正常工作。应该在浏览器(开发人员控制台)中看到该输出。。可能是错误消息。应该在浏览器(开发人员控制台)中看到该输出。。可能是错误信息。可能是旧文件中的UTF-8 BOM?我不知道。声明如下:因为此文件还包含html代码。BOM“不可见”(不可打印字符)。。任何像样的文本编辑器都会告诉你文件的编码。也许旧文件中有UTF-8 BOM?我不知道。声明如下:因为此文件还包含html代码。BOM“不可见”(不可打印字符)。。任何合适的文本编辑器都会告诉您文件的编码。