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

使用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

  • 写回答

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;
    //==============================================================
    //==============================================================
    //==============================================================
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里