【问题标题】:PHP mPDF Certificate Printing with Customer Name and PointsPHP mPDF证书打印与客户名称和积分
【发布时间】:2016-06-02 19:29:34
【问题描述】:

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

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

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

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

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

【问题讨论】:

    标签: php pdf-generation mpdf


    【解决方案1】:

    我得到了解决方案,就是了解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;
    
        //==============================================================
        //==============================================================
        //==============================================================
    
        ?>
    

    祝你好运!

    【讨论】:

      猜你喜欢
      • 2012-01-31
      • 2011-07-14
      • 2010-10-29
      • 1970-01-01
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多