douxia6554
2014-01-30 13:32
浏览 422
已采纳

使用MPDF以PDF格式覆盖页面

I have an html page that has borders around, but when I use the MPDF, he breaks a div and not puts border above or down of the broken div, does anyone know how to fix it, or let each page with border around?Image of pdf

图片转代码服务由CSDN问答提供 功能建议

我有一个带有边框的html页面,但是当我使用MPDF时,他打破了一个div而不是put 在破坏的div上方或下方的边界,是否有人知道如何修复它,或者让每个页面都有边框?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyi9082 2015-01-26 23:42
    已采纳

    Perhaps you could try a hack using watermarks:

    http://www.olivettorestaurante.com.br/mpdf/examples/example35_watermarks.php

    A full page square image used as watermark could work. I know, a bit triky, but sometimes MPDF turns weird when facing some problems... :/

    A better answerd would be wellcome. Here is the sampl code available in the MPDF examples directory, related to watermarks:

    <?php
    $html = '
    <h1>mPDF</h1>
    <h2>Watermarks</h2>
    <p>P: Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut aeros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci.</p>
    <hr />
    <div>DIV: Proin aliquet lorem id felis. Curabitur vel libero at mauris nonummy tincidunt. Donecimperdiet. Vestibulum sem sem, lacinia vel, molestie et, laoreet eget, urna. Curabitur viverra faucibus pede. Morbi lobortis. Donec dapibus. Donec tempus. Ut arcu enim, rhoncus ac, venenatis eu, porttitor mollis, dui. Sed vitae risus. In elementum sem placerat dui. Nam tristique eros in nisl. Nulla cursus sapien non quam porta porttitor. Quisque dictum ipsum ornaretortor. Fusce ornare tempusenim. </div>
    <div>DIV: Proin aliquet lorem id felis. Curabitur vel libero at mauris nonummy tincidunt. Donecimperdiet. Vestibulum sem sem, lacinia vel, molestie et, laoreet eget, urna. Curabitur viverrafaucibus pede. Morbi lobortis. Donec dapibus. Donec tempus. Ut arcu enim, rhoncus ac, venenatis eu, porttitor mollis, dui. Sed vitae risus. In elementum sem placerat dui. Nam tristique eros in nisl. Nulla cursus sapien non quam porta porttitor. Quisque dictum ipsum ornaretortor. Fusce ornare tempusenim. </div>
    <blockquote>Blockquote: Maecenas arcu justo, malesuada eu, dapibus ac, adipiscing vitae, turpis. Fusce mollis. Aliquam egestas. In purus dolor, facilisis at, fermentum nec, moestie et, metus. Maecenas arcu justo, malesuada eu, dapibus ac, adipiscing vitae, turpis. Fusce mollis. liquam egestas. In purus dolor, facilisis at, fermentum nec, molestie et, metus.</blockquote>
    <address>Address: Vestibulum feugiat, orci at imperdiet tincidunt, mauris erat facilisis urna, sagittis ultricies dui nisl et lectus. Sed lacinia, lectus vitae dictum sodales, elit ipsum ultrices orci, non euismod arcu diam non metus </address>
    ';
    //==============================================================
    //==============================================================
    //==============================================================
    include("../mpdf.php");
    $mpdf=new mPDF('c');
    $mpdf->SetDisplayMode('fullpage');
    $mpdf->SetWatermarkText('DRAFT');
    $mpdf->watermark_font = 'DejaVuSansCondensed';
    $mpdf->showWatermarkText = true;
    $mpdf->WriteHTML($html);
    $mpdf->AddPage();
    $mpdf->SetWatermarkImage('tiger.wmf', 1, '', array(160,10));
    $mpdf->showWatermarkImage = true;$mpdf->WriteHTML('<h2>Using a Watermark as a Header</h2>');
    $mpdf->WriteHTML($html);
    $mpdf->AddPage();
    $mpdf->SetWatermarkImage('tiger.wmf', 0.15, 'F');
    $mpdf->WriteHTML('<h2>Using a Watermark Image as Background</h2>');
    $mpdf->WriteHTML($html);
    $mpdf->Output();
    exit;
    //==============================================================
    //==============================================================
    //==============================================================
    ?>
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongxia527680 2017-03-24 11:52

    you can create a container with border like this:

        <head>
          <style>
               #page-border{
                   width: 100%;
                   height: 100%;
                   border:4px double black;
               }
          </style>
        </head>
        <body>
            <div id="page-border">
                 .... content ....
            </div>
        </body>
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题