mPDF:如何删除setHeader()& setFooter()边框

时间:2017-03-18 11:51:29

标签: php mpdf

我的系统和报告中有mPDF报告,它有一个页眉和页脚,我使用$mpdf->setHeader();& $mpdf->setFooter();设置页眉和页脚。但它显示页眉的顶部边框和页脚的顶部边框。任何人都可以帮我解决这个问题吗?

见图像:

enter image description here

这是我的代码:

$mpdf=new mPDF('','LETTER-L','','',35,35,60,25,10,10);
//left margin, right margin, body, top margin,top margin,bottom margin, 

/*HEADER Monthly Accomplishment Report*/
$mpdf->SetHeader('Sample');


/*FOOTER xMonthly Accomplishment Report*/
$mpdf->SetFooter('Sample');




//==============================================================
//=====================FILE DESCRIPTION=========================
//==============================================================
$mpdf->SetTitle('Monthly Accomplishment Report');
$mpdf->SetSubject('Report');
$mpdf->SetAuthor('sample');
$mpdf->Output('sample.pdf','I');
exit;
//==============================================================
//==============================================================
//==============================================================

2 个答案:

答案 0 :(得分:4)

您可以改用这两个mpdf属性:

$mpdf->defaultheaderline = 0;
$mpdf->defaultfooterline = 0;

答案 1 :(得分:0)

我查看了方法setHeader的文档,发现存在line参数:

  

$ line:指定是否在标题下绘制一行

您已将string传递给该方法,但也接受了一系列选项

文档中提到的

$line并不是该方法的参数,而是配置数组的一个关键字。

因此,根据文档,此代码应完成您所需的内容:

$mpdf = new mPDF('','LETTER-L','','',35,35,60,25,10,10);
$headerFooterContent = 'Sample';
$oddEvenConfiguration = 
 [
    'L' => [ // L for Left part of the header
      'content' => '',
    ],
    'C' => [ // C for Center part of the header
      'content' => '',
    ],
    'R' => [
      'content' => $headerFooterContent,
    ],
    'line' => 0, // That's the relevant parameter
  ];
$headerFooterConfiguration = [
  'odd' => $oddEvenConfiguration,
  'even' => $oddEvenConfiguration
];
$mpdf->SetHeader($headerFooterConfiguration);
$mpdf->SetFooter($headerFooterConfiguration);

setHeadersetFooter方法接受相同的参数(它们几乎在库中复制/粘贴)。

我让你进一步了解mPDF的specific part of the examples related to complex header configuration

如果它能解决您的问题,请告诉我。