mPDF setAutoMargin对第一页不起作用 [英] mPDF setAutoMargin not working for first page

查看:139
本文介绍了mPDF setAutoMargin对第一页不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码可完美地用于第二,第三等页面,但不适用于第一页面.

The following code works perfectly for the second, third etc pages, but not for the first one.

/*
 * Encoding
 * Size (A4, etc)
 * Font-size
 * Font-type
 * margin_left
 * margin_right
 * margin_top
 * margin_bottom
 * margin_header
 * margin_footer
 * Orientation
 */
$this->mPDF = new mPDF('utf-8', 'A4', 9, 'freesans', 10, 10, 0, 25, 5, 4, 'P');
$this->mPDF->setAutoTopMargin = 'pad';

$html = '<sethtmlpageheader name="myheader" value="on" show-this-page="1"></sethtmlpageheader>';

在第一页中,正文内容与标题内容重叠,而在其他页面上,正文内容与标题内容不重叠,并且恰好位于标题下方.

In the first page, the body content overlap the header content, while on the other pages the body content doesn't overlap the header content and fits perfectly below the header.

我希望在首页上具有相同的行为,该怎么办?

I want the same behavior on the first page, how do I do it?

编辑1 : 一张图像来说明我面临的问题

EDIT 1: An image to illustrate the problem I'm facing

推荐答案

我找到了这个答案 http://www.mpdf1.com/forum/discussion/621/margin-top-problems/p1 基本上报告了我的问题. 解决方案是添加并删除页面,以便代码计算页边距,然后再次添加页面.

I found out this answer http://www.mpdf1.com/forum/discussion/621/margin-top-problems/p1 which basically reports my issue. The solution is to add a page and delete it so the code calculates the margins and then add again the page.

$this->mPDF->WriteHTML($html);
$this->mPDF->page = 0;
$this->mPDF->state = 0;
unset($this->mPDF->pages[0]);

这篇关于mPDF setAutoMargin对第一页不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆