dongsi3826 2017-03-05 16:54
浏览 208

MPFD中的自定义尺寸纸张

i tried for set custom size paper in MPDF like this

$mpdf = new mPDF('utf-8', array(190,236));

but cannot work, anyone know how it's work?

  • 写回答

1条回答 默认 最新

  • dongzhong7299 2017-03-05 17:17
    关注

    I just tested your class initialization in the included example example01_basic.php and it's working fine. Maybe you just don't recognize the difference with your eyes. Try something more visible like $mpdf = new mPDF('utf-8', array(130, 130));.

    Give it a try with this example file:

    $html = '<h1>my test headline</h1><p>that is my body text</p>';
    require_once __DIR__ . '/../vendor/autoload.php';
    $mpdf = new mPDF('utf-8', array(130, 130));
    
    $mpdf->WriteHTML($html);
    $mpdf->Output();
    exit;
    

    Edit:

    As you pointed out in your comment, you want to change the margin of the page. You could edit the page styles via CSS.

    For testing add the following CSS Snippet to your PDF included HTML:

    <style>
    @page {
        margin-top: 10mm;
        margin-bottom: 10mm;
        margin-left: 5mm;
        margin-right: 5mm;
    }
    </style>
    

    If you want to style your page for production use, you should take a look in the MPDF included example13_paging_css.php. Here you can see the recommended way to use stylesheets in MPDF.

    // LOAD a stylesheet
    $stylesheet = file_get_contents('mpdfstylePaged.css');
    $mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text
    
    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题