带有客户名称和积分的PHP mPDF证书打印

时间:2016-02-21 11:32:38

标签: php pdf-generation mpdf

我必须生成带有背景图像的PDF证书文件 - A4尺寸作为修复格式证书文件和动态运行时间Participant NameWinning Points,使用mPDF在生成的PDF中提到。

现在的问题是,我使用PDF生成的证书是横向文本,文本应该相应地放在那里。

我尝试使用html / css - text transform 90 degree method,但这不支持PDF生成代码。

证书文件:http://goo.gl/kV576i

解决此问题的任何快速技巧。

1 个答案:

答案 0 :(得分:0)

我得到了解决方案,关于理解mPDF结构和页面添加方法如下:

    include("../mpdf.php");

    $mpdf = new mPDF('c','A4','','',42,15,67,67,20,15);
    $mpdf->SetDisplayMode('fullpage');
    $mpdf->AddPage('L','','','','',25,25,55,45,18,12);
    $mpdf->WriteHTML($html);
    $mpdf->Output('mpdf.pdf','I');
    exit;

以下是包含CSS和其他设置的完整代码,以防万一对某人有用:

    <?php

    $html = '
    <style style="text/css">
    body {
      background-image: url("background-image.jpg");
      background-image-resize: 6; // mpdf style class
    }
    .centrar{
        position: absolute;
        border: 0px solid red;
        width: 100%;
        left: 0 auto;
        top: 40%;
        text-align: center;
        font-size: 2em;
        font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;
        font-weight: bold;
    }
    .points{
        position: absolute;
        border: 0px solid green;
        width: 63.5%;
        left: 0 auto;
        top: 64.7%;
        text-align: center;
        font-size: 1.5em;
        font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;
        font-weight: bold;
    }
    </style>
    <p class="centrar">'. ucwords('some name here') .'</p>
    <p class="centrar points">30</p>
    ';

    //==============================================================
    //==============================================================
    //==============================================================

    include("../mpdf.php");

    $mpdf = new mPDF('c','A4','','',42,15,67,67,20,15);
    $mpdf->SetDisplayMode('fullpage');
    $mpdf->AddPage('L','','','','',25,25,55,45,18,12);
    $mpdf->WriteHTML($html);
    $mpdf->Output('mpdf.pdf','I');
    exit;

    //==============================================================
    //==============================================================
    //==============================================================

    ?>

祝你好运!