:::

16-2 上課範例:admin/pdf.php

<?php
include_once "header_admin.php";
require_once('../class/tcpdf/config/lang/zho.php');
require_once('../class/tcpdf/tcpdf.php');

//實體化PDF物件
$pdf = new TCPDF("L", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->setPrintHeader(false); //不要頁首
$pdf->setPrintFooter(false); //不要頁尾

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);  //設定自動分頁

$pdf->setLanguageArray($l); //設定語言相關字串

$pdf->setFontSubsetting(true); //產生字型子集(有用到的字才放到文件中)

$pdf->SetFont('droidsansfallback', '', 12, '', true); //設定字型

$pdf->AddPage(); //新增頁面

$pdf->setTextShadow(array('enabled'=>false, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));//文字陰影



$sql = "select * from `".$xoopsDB->prefix("contact")."` ";
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());

$all_content="";
$cate=get_contact_cate_all();

while($all=$xoopsDB->fetchArray($result)){
	//以下會產生這些變數: $tel , $email , $name , $gsn , $sn , $birthday , $zip , $county , $city , $addr
	foreach($all as $k=>$v){
		$$k=$v;
	}

	$all_content.="
	<tr>
		<td>{$cate[$gsn]['title']}</td>
		<td>{$name}</td>
		<td>{$tel}</td>
		<td>{$email}</td>
		<td>{$birthday}</td>
		<td>{$zip} {$county}{$city}{$addr}</td>
	</tr>
	";
}


$html="<h1>通訊錄</h1>
<table border=\"1\" cellpadding=\"4\">
	<tr bgcolor=\"#FFFF66\" align=\"center\">
		<th width=\"40\">群組</th>
		<th>姓名</th>
		<th>電話</th>
		<th>信箱</th>
		<th>生日</th>
		<th width=\"200\">地址</th>
	</tr>
	$all_content
</table>";

$pdf->writeHTML($html);

$pdf->Output('contact.pdf', 'I');

?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D808%26tbsn%3D26

書籍目錄

展開 | 闔起

線上使用者

38人線上 (12人在瀏覽線上書籍)

會員: 0

訪客: 38

更多…