你好我試圖用HTML2PDF創建一個包含在VICH表中的PHP文件的PDF日從MySQL數據庫中的數據取出,並通過使用while循環產生 但聞一TR運行PHP文件
它說follwoing錯誤 TCPDF ERROR:一些數據已輸出,不能發送PDF文件[在這裏輸入的形象描述] [1] ñ任何人的幫助我在解決問題請 這裏是我的代碼,使用HTML2PDF API保存在PHP和HTML表格生成MySQL數據
<?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//error_reporting(0);
/*
Author : yaser kazi
Description : This File Contain Additions and Editing part for the Paxes
*/
if (!isset($_SESSION["username"])) {
header("location: unauthorize_access.html");
exit();
}
if (isset($_GET["cityprin"])) {
mysql_connect("localhost", "root", '') or die(mysql_error());
mysql_select_db('webapp') or die(mysql_error());
$get = mysql_query("SELECT code, `name` FROM city ORDER BY `name`") or die(mysql_error());
$ctr = 0;
ini_set("memory_limit", "50M");
ob_start();
?>
<style type="text/css" media="all">
<!--
body {
margin:0px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
span {
font-size:14px;
}
td {
width: 100mm;
max-width: 100mm;
height: 33mm;
max-height:33mm;
top:0mm;
}
table {
border-collapse:collapse;
}
-->
</style>
<?php
echo "<table border=\"1\" align=\"right\" style =\"width: 205mm;\">";
echo "<th>Srno</th>";
echo "<th>Code</th>";
echo "<th>Name</th>";
while ($city = mysql_fetch_array($get)) {
$ctr++;
echo "<td style=\"width: 100mm; max-width: 100mm; height:33mm; padding-left:1mm;\" valign=\"right\">".$ctr."</td>";
echo "<td style=\"width: 100mm; max-width: 100mm; height:33mm; padding-left:7mm;\" valign=\"right\">".$city['code']."</td>";
echo "<td style=\"width: 100mm; max-width: 100mm; height:33mm; padding-left:7mm;\" valign=\"right\">".$city['name']."</td>";
}
echo "</table>";
} // Submit Tag Close
?>
<?php
$content = ob_get_clean();
// conversion HTML => PDF
require_once('html2pdf/html2pdf.class.php');
try {
$html2pdf = new HTML2PDF('P', 'A4', 'EN', false, 'ISO-8859-15', array("5mm", "13mm", "0mm", "0mm"));
$html2pdf->pdf->SetAuthor('CepheiSys');
$html2pdf->pdf->SetTitle('City_list');
// $html2pdf->pdf->SetSubject('HTML2PDF Wiki');
// $html2pdf->pdf->SetKeywords('HTML2PDF, TCPDF, example, wiki');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content);
$html2pdf->Output('City_list.pdf');
} catch (HTML2PDF_exception $e) {
echo $e;
}
?>
如果查看HTML,而不是生成的PDF會發生什麼想法? – cimmanon
它顯示了一個錯誤 TCPDF錯誤:某些數據已經被輸出,不能發送PDF文件[在這裏輸入的形象描述] [1] – john
可以uplease幫我解決這個問題 – john