亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP使用mpdf實(shí)現(xiàn)導(dǎo)出pdf文件功能

 更新時(shí)間:2024年04月25日 11:21:00   作者:cq林志炫  
這篇文章主要為大家詳細(xì)介紹了PHP如何使用mpdf實(shí)現(xiàn)導(dǎo)出pdf文件功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下

mpdf的開發(fā)文檔地址:

Supported CSS – CSS & Stylesheets – mPDF Manual

1.加載依賴庫(kù)

composer require mpdf/mpdf

2.頁(yè)面

$html = <<<EOD
 
 
<body style="background:url($img1);"  lang="zh-CN">
    <div style="background:rgba(255,255,255,0.3);">
        <div style="width: 12rem;height: 15rem;float: right;">
            $avatar
        </div>
        <div style="padding-top: 5rem;padding-left: 2rem;">
            <span style="font-size: 20pt;font-weight: bold;">$strTitle</span>
<table  style="color: #666666;padding-top: 1rem;font-size: 14pt;line-height: 16pt;" >
                <tr>
                    <td style="">
                    姓名:$studentName
                    </td>
                    <td style="padding-left: 2rem;">
                    性別:$sex
                    </td>
                    <td style="">
                    出生年月:$birthday
                    </td>
                </tr>
                <tr>
                    <td>
                    民族:$nationality
                    </td>
                    <td style="">
                    政治面貌:$political
                    </td>
                    <td style="padding-left: 2rem;">
                    電話:$phone
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div style="background-color: white;padding-bottom: initial;">
 
    <table   style="text-align:center;font-size:20pt;"  >
    </table>
    
 
 
<h2></h2><h2></h2>
<h2 style="padding-left: 2rem">技能特長(zhǎng)</h2>
<table  style="text-align:left;line-height:200%;font-size:14pt;color: #666666;" >
$strSkills
</table>
 
 
<h2></h2>
<h2 style="padding-left: 2rem">成績(jī)單</h2>
<table  style="text-align:left;line-height:200%;font-size:12pt;border-collapse: collapse;margin-left: 2rem;width: 95%;" >
<tr >
<th style="border: 1px solid black;border-right: 0px;">總分:$scoreTotal</th>
<th style="border: 1px solid black;border-right: 0px;border-left: 0px;"></th>
<th style="border: 1px solid black;border-right: 0px;border-left: 0px;"></th>
<th style="border: 1px solid black;border-right: 0px;border-left: 0px;"></th>
<th style="border: 1px solid black;border-left: 0px;"></th>
</tr>
$strActivity
</table>
 
 
 
<h2></h2>
<h2 style="padding-left: 2rem;">獲獎(jiǎng)證書</h2>
<table  style="text-align:left;line-height:200%;font-size:12pt;border-collapse: collapse;margin-left: 2rem;width: 95%;" >
<tr>
<th style="border: 1px solid black;color: #333333;">項(xiàng)目名稱</th>
<th style="border: 1px solid black;color: #333333;">等級(jí)</th>
<th style="border: 1px solid black;color: #333333;">獲得時(shí)間</th>
<th style="border: 1px solid black;color: #333333;">經(jīng)歷描述</th>
</tr>
$strCertificate
 
</table>
 
 
 
 
<h2></h2>
<h2 style="padding-left: 2rem;">實(shí)踐經(jīng)歷</h2>
$strTraining
 
<h2></h2>
<h2 style="padding-left: 2rem;">個(gè)人風(fēng)采</h2>
$strPersona
 
 
    </div>
</body>
    		
EOD;

3.導(dǎo)出

require_once 'vendor/autoload.php';
        $mpdf=new Mpdf([
            'mode' => '',
            'format' => 'A4',
            'default_font_size' => 0,
            'default_font' => 'sans',
            'margin_left' => 10,
            'margin_right' => 10,
            'margin_top' => 10,
            'margin_bottom' => 10,
            'margin_header' => 9,
            'margin_footer' => 9,
            'orientation' => 'P',
        ]);
        $mpdf->useAdobeCJK = true;
        $mpdf->autoScriptToLang = true;//支持中文設(shè)置
        $mpdf->autoLangToFont = true;//支持中文設(shè)置
        $mpdf->setAutoTopMargin = 'stretch';//設(shè)置自動(dòng)頂部邊距
        $mpdf->setAutoBottomMargin = 'stretch';//設(shè)置自動(dòng)低部邊距
        $mpdf->AddPage();
 
        //獲取配置文字或者logo
        $conf=M("confScoreList")->find();
        //設(shè)置頁(yè)眉
        $SetHeader = '<table class="header" style="text-align: right;width: 100%;"> 
<tr>
   <td width="33%" style="text-align: left;font-size: 10pt;color: #999999;"> <img src="'.K_PATH_IMAGES.$conf['logo'].'" alt=""> </td>
   <td width="33%" style="text-align: right;color: #999999;">'.$conf['headerRight'].'</td>
   </tr>
</table>';
 
        $mpdf->SetHeader($SetHeader);
        //這是一個(gè)頁(yè)腳的范例{PAGENO}是當(dāng)前的頁(yè)數(shù),{nb}是總共的頁(yè)數(shù)
        //<td width="33%" style="text-align: center;font-size: 10pt;">第 {PAGENO} 頁(yè)&nbsp;&nbsp;&nbsp;&nbsp;共 {nb} 頁(yè)</td>
        $setFooter = '<table class="footer" style="text-align: right;width: 100%;"> 
<tr>
   <td width="33%" style="text-align: left;font-size: 10pt;color: #999999;">'.$conf['footerLeft'].'</td>
   <td width="33%" style="text-align: right;color: #999999;">'.$conf['footerRight'].'</td>
   </tr>
</table>';
 
        $mpdf->setFooter($setFooter);
        //設(shè)置中文編碼
        $mpdf->WriteHTML($html);
        //導(dǎo)出pdf文件重命名
//        $mpdf->Output($dataResume['resumeName'] . '.pdf', true);
        $mpdf->Output();
        exit;

到此這篇關(guān)于PHP使用mpdf實(shí)現(xiàn)導(dǎo)出pdf文件功能的文章就介紹到這了,更多相關(guān)PHP mpdf導(dǎo)出pdf內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能【便于整體打印輸出】

    PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能【便于整體打印輸出】

    這篇文章主要介紹了PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能,可實(shí)現(xiàn)多張圖片的合并,便于整體打印輸出.涉及php字符串、數(shù)組的遍歷、排序及圖片合成、裁剪、縮放等相關(guān)操作技巧,需要的朋友可以參考下
    2017-11-11
  • php淺析反序列化結(jié)構(gòu)

    php淺析反序列化結(jié)構(gòu)

    序列化其實(shí)就是將數(shù)據(jù)轉(zhuǎn)化成一種可逆的數(shù)據(jù)結(jié)構(gòu),自然,逆向的過(guò)程就叫做反序列化。php將數(shù)據(jù)序列化和反序列化會(huì)用到兩個(gè)函數(shù):serialize?將對(duì)象格式化成有序的字符串、unserialize?將字符串還原成原來(lái)的對(duì)象
    2022-07-07
  • PHP版QQ互聯(lián)OAuth示例代碼分享

    PHP版QQ互聯(lián)OAuth示例代碼分享

    這篇文章主要介紹了PHP版QQ互聯(lián)OAuth示例代碼分享,十分的詳細(xì)使用,有需要的小伙伴可以參考下。
    2015-07-07
  • 基于PHP創(chuàng)建Cookie數(shù)組的詳解

    基于PHP創(chuàng)建Cookie數(shù)組的詳解

    本篇文章是對(duì)在PHP中創(chuàng)建Cookie數(shù)組的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-07-07
  • WebQQ最新登陸協(xié)議的用法

    WebQQ最新登陸協(xié)議的用法

    這篇文章主要介紹了WebQQ最新登陸協(xié)議的用法,分析了WebQQ協(xié)議的原理與用法,具有一定的實(shí)用價(jià)值,需要的朋友可以參考下
    2014-12-12
  • 基于PHP實(shí)現(xiàn)個(gè)人博客網(wǎng)站

    基于PHP實(shí)現(xiàn)個(gè)人博客網(wǎng)站

    這篇文章主要為大家介紹了利用PHP+HTML制作一個(gè)個(gè)人博客網(wǎng)站,文中的示例代碼講解詳細(xì),感興趣的小伙伴快跟隨小編一起了解一下
    2022-04-04
  • PHP文本操作類

    PHP文本操作類

    PHP文本操作類...
    2006-11-11
  • php中JSON的使用方法

    php中JSON的使用方法

    json常用來(lái)作為數(shù)據(jù)交換的一種格式,和xml相比體積更小。缺點(diǎn)就是層級(jí)關(guān)系不明顯不大容易被理解。php中生成json要借助array和json_encode,json_decode一起使用。越復(fù)雜的json嵌套的數(shù)組越多,下面我們來(lái)仔細(xì)探討下這個(gè)問(wèn)題。
    2015-04-04
  • php將金額數(shù)字轉(zhuǎn)化為中文大寫

    php將金額數(shù)字轉(zhuǎn)化為中文大寫

    本文給大家匯總介紹了幾種php將金額數(shù)字轉(zhuǎn)化為中文大寫的實(shí)用函數(shù),各有優(yōu)劣,小伙伴們根據(jù)自己的項(xiàng)目需求自由選擇吧。
    2015-07-07
  • PHP中常用的字符串格式化函數(shù)總結(jié)

    PHP中常用的字符串格式化函數(shù)總結(jié)

    這篇文章主要介紹了PHP中常用的字符串格式化函數(shù)總結(jié),本文講解的函數(shù)是WEB中經(jīng)常用到的,例如取出空格和字符串填補(bǔ)函數(shù)、字符串大小寫的轉(zhuǎn)換、和HTML標(biāo)簽相關(guān)的字符串格式化等,需要的朋友可以參考下
    2014-11-11

最新評(píng)論