17-3
上課範例:admin/pdf_all.php
02 | include_once "header_admin.php" ; |
03 | include_once "../up_file.php" ; |
04 | require_once ( '../class/tcpdf/config/lang/zho.php' ); |
05 | require_once ( '../class/tcpdf/tcpdf.php' ); |
07 | $sn = empty ( $_REQUEST [ 'sn' ])? "0" : intval ( $_REQUEST [ 'sn' ]); |
10 | $pdf = new TCPDF( "L" , PDF_UNIT, "A5" , true, 'UTF-8' , false); |
14 | $pdf ->SetMargins(25, 25); |
15 | $pdf ->setHeaderMargin(5); |
16 | $pdf ->setFooterMargin(10); |
18 | $pdf ->setHeaderData( 'ck2.jpg' , 40, '我的通訊錄' , 'http://163.26.52.243/~tad0616/modules/contact' , array (27,49,0), array (71,71,70)); |
19 | $pdf ->setFooterData( array (27,49,0), array (71,71,70)); |
20 | $pdf ->setHeaderFont( array ( 'droidsansfallback' , 'B' , '14' )); |
21 | $pdf ->setFooterFont( array ( 'droidsansfallback' , 'I' , '16' )); |
23 | $pdf ->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); |
25 | $pdf ->setLanguageArray( $l ); |
27 | $pdf ->setFontSubsetting(true); |
29 | $pdf ->SetFont( 'droidsansfallback' , '' , 12, '' , true); |
33 | $sql = "select * from `" . $xoopsDB ->prefix( "contact" ). "`" ; |
34 | $result = $xoopsDB ->query( $sql ) or redirect_header( $_SERVER [ 'PHP_SELF' ],3, mysql_error()); |
37 | $cate =get_contact_cate_all(); |
39 | while ( $all = $xoopsDB ->fetchArray( $result )){ |
41 | foreach ( $all as $k => $v ){ |
47 | $pdf ->setTextShadow( array ( 'enabled' =>false, 'depth_w' =>0.2, 'depth_h' =>0.2, 'color' => array (196,196,196), 'opacity' =>1, 'blend_mode' => 'Normal' )); |
50 | $photo_file =get_pic_file( 'photo' , $sn , 1); |
51 | $photo = empty ( $photo_file )? "" : "<img src=\"{$photo_file}\">" ; |
53 | $html ="<h1>「{ $name }」通訊錄</h1> |
54 | <table border=\"1\" cellpadding=\"4\"> |
55 | <tr><th width=\"50\" align=\"center\" bgcolor=\"#CCFF66\">電話</th><td width=\"200\">{ $tel }</td> |
56 | <td width=\"200\" rowspan=\"4\"> $photo </td></tr> |
57 | <tr><th align=\"center\" bgcolor=\"#CCFF66\">信箱</th><td>{ $email }</td></tr> |
58 | <tr><th align=\"center\" bgcolor=\"#CCFF66\">生日</th><td>{ $birthday }</td></tr> |
59 | <tr><th align=\"center\" bgcolor=\"#CCFF66\">地址</th><td>{ $zip } { $county }{ $city }{ $addr }</td></tr> |
62 | $pdf ->writeHTML( $html ); |
64 | include_once XOOPS_ROOT_PATH. "/modules/tadtools/qrcode/qrcode.php" ; |
65 | $a = new QR( "Email:{$email}" ); |
66 | file_put_contents (XOOPS_ROOT_PATH. "/uploads/qrcode/{$sn}.gif" , $a ->image(2)); |
69 | $pdf ->Image(XOOPS_URL. "/uploads/qrcode/{$sn}.gif" , 170, 22 , 15, 15, 'gif' ); |
72 | $pdf ->Output( 'contact.pdf' , 'I' ); |