:::

17-2 上課範例:admin/pdf2.php

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

$sn=empty($_REQUEST['sn'])?"0":intval($_REQUEST['sn']);

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

$pdf->SetMargins(25, 25);
$pdf->setHeaderMargin(5);
$pdf->setFooterMargin(10);

$pdf->setHeaderData('ck2.jpg', 40, '我的通訊錄', 'http://163.26.52.243/~tad0616/modules/contact', array(27,49,0), array(71,71,70));
$pdf->setFooterData(array(27,49,0), array(71,71,70));
$pdf->setHeaderFont(array('droidsansfallback','B','14'));
$pdf->setFooterFont(array('droidsansfallback','I','16'));

$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")."` where sn='$sn'";
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());

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

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

$photo_file=get_pic_file('photo' , $sn , 1);
$photo="<img src=\"{$photo_file}\">";

$html="<h1>「{$name}」通訊錄</h1>
<table border=\"1\" cellpadding=\"4\">
<tr><th width=\"50\" align=\"center\" bgcolor=\"#CCFF66\">電話</th><td width=\"200\">{$tel}</td>
<td width=\"200\" rowspan=\"4\">$photo</td></tr>
<tr><th align=\"center\" bgcolor=\"#CCFF66\">信箱</th><td>{$email}</td></tr>
<tr><th align=\"center\" bgcolor=\"#CCFF66\">生日</th><td>{$birthday}</td></tr>
<tr><th align=\"center\" bgcolor=\"#CCFF66\">地址</th><td>{$zip} {$county}{$city}{$addr}</td></tr>
</table>";

$pdf->writeHTML($html);

include_once XOOPS_ROOT_PATH."/modules/tadtools/qrcode/qrcode.php";
$a = new QR("Email:{$email}");
file_put_contents(XOOPS_ROOT_PATH."/uploads/qrcode/{$sn}.gif",$a->image(2));

  
$pdf->Image(XOOPS_URL."/uploads/qrcode/{$sn}.gif", 150, 22 , 15, 15, 'gif');


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



?>

 


:::

搜尋

QR Code 區塊

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

書籍目錄

展開 | 闔起

線上使用者

34人線上 (27人在瀏覽線上書籍)

會員: 0

訪客: 34

更多…