php html mpdf自动转换并生成pdf文件

<?php
require 'mpdf.php';
$str = '
    <table  style="border-collapse: collapse; width: 900px; height: 56px; font-family: 宋体; font-size: 18px; position: relative;">
    <tbody>
        <tr style="height:75px;text-align:center" class="firstRow">
            <!--<td style="font-weight: bold;font-size:40px;text-align:center" colspan="2">
                <img src="images/order_logo.png">
            </td>-->
            <td style="font-weight: bold;font-size:40px;text-align:center" colspan="8">
                《出库单》
            </td>
            <!--<td style="font-weight: bold;font-size:40px;text-align:right" colspan="2">
                <img src="条形码.jpg" width="300px" height="54px">
            </td>-->
        </tr>
        <tr>
            <td style="border-bottom: 1px solid #ccc;font-size:28px;text-align:right" colspan="8">
                合同号XXXXXX
            </td>
        </tr>
        <tr style="height:75px;"><td colspan="8">&nbsp;</td></tr>
        <tr style="height:40px;text-align:left;">
            <td style="font-weight: normal;font-size:12px;" colspan="4">
                【打印时间】2019/07/09 03:44:35
            </td>
            <td style="font-weight: normal;font-size:12px;text-align:right">
                【客户国家】
            </td>
            <td style="font-weight: normal;font-size:12px;" colspan="3">
                XXXXX
            </td>
        </tr>
        <tr style="height:75px;"><td colspan="8">&nbsp;</td></tr>
        <tr style="height:40px;text-align:left">
            <td style="font-weight: normal;font-size:12px;" colspan="4">
                【录入时间 】2019-07-09 12:29:05 
            </td>
            <td style="font-weight: normal;font-size:12px;text-align:right">
                【运输方式】
            </td>
            <td style="font-weight: normal;font-size:12px;" colspan="3">
                XXXXXXXXXXXXXX
            </td>
        </tr>
        <tr style="height:75px;"><td colspan="8">&nbsp;</td></tr>
        <tr style="height:40px;text-align:left">
            <td style="font-weight: normal;font-size:12px;" colspan="1">
                【付款方式】
            </td>
            <td style="font-weight: normal;font-size:12px;" colspan="3">
                XXXXXXXXXXXX
            </td>
            <td style="font-weight: normal;font-size:12px;text-align:right">
                【客户备注】
            </td>
            <td style="font-weight: normal;font-size:12px;" colspan="3">
                XXXXXXXXXX
            </td>
        </tr>
        <tr style="height:75px;"><td colspan="8">&nbsp;</td></tr>
        <tr style="height:40px;text-align:left">
            <td style="font-weight: normal;font-size:12px;" colspan="2">
                【业务助理/业务员/填单助理】:
            </td>
            <td style="font-weight: normal;font-size:12px;" colspan="6">
                XXXXXXXXXXXXX
            </td>
        </tr>
        <tr style="height:75px;"><td colspan="8" style="border-bottom: 1px solid #ccc;">&nbsp;</td></tr>
        
        <tr style="height:75px;"><td colspan="8">&nbsp;</td></tr>
        <tr style="height:32px;text-align:center;font-size:14px">
            <td style="border: 1px solid #ccc;font-weight: normal; width: 8%;text-align:center;font-size:14px;">
                ID
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal; width: 19%;text-align:center;font-size:14px;">
                产品名称
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal; width: 8%;text-align:center;font-size:14px;">
                主产品ID
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal; width: 5%;text-align:center;font-size:14px;">
                数量
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;width: 17%;text-align:center;font-size:14px;">
                特性备注
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;width: 16%;text-align:center;font-size:14px;">
                装箱单标签
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;width: 10%;text-align:center;font-size:14px;">
                发货区
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;width: 17%;text-align:center;font-size:14px;">
                采购人及备注
            </td>
        </tr>
        <tr style="height:32px;text-align:center;font-size:14px;text-align:center">
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                <img src="产品.jpg" width="50px" height="50px"><br>
                #42465
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                XXXXXXXXXXXX
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                5
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                标签描述: XXXXXXXXX
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                XXXXXXXXXXXXX
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                XXXXXXXXXXX
            </td>
            <td style="border: 1px solid #ccc;font-weight: normal;text-align:center;font-size:14px;">
                XXXXXXXXXXXXX
            </td>
        </tr>
    </tbody>
</table>
';
$mpdf = new mPDF('utf-8', 'A4', 16, '', 10, 10, 15, 1);
$mpdf->SetDisplayMode('fullpage');
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($str, 2);
//$mpdf->Output('mpdf.pdf', 'I'); //D是下载
//$mpdf->Output('mpdf.pdf', 'D'); //D是下载
$mpdf->Output(iconv("utf-8","GB2312","D:/MYOA/pdf/生成PDF.pdf"));//将生成的pdf文件存在指定的路径里
?>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hai7425

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值