我想使用mpdf在pdf中设置页眉和页脚 [英] I want to set header and footer in pdf using mpdf
本文介绍了我想使用mpdf在pdf中设置页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在 Codeigniter $ c $中使用
mpdf
库生成了一个 PDF
C>。
我想用适当的边距连接页眉图像和页脚图像,我创建了一个代码,但页眉和页脚重叠请帮助我解决此问题
提前致谢
//控制器
$ this->加载 - >库('m_pdf');
$ param =',A4,,,0,0,100,0,6,3,L';
$ pdf = $ this-> m_pdf->加载($ param);
// $ pdf-> useOddEven = true;
$ pdf-> SetHTMLHeader('< img src =''。base_url()。'custom / Hederinvoice.jpg/>');
$ pdf-> SetHTMLFooter('< img src =''。base_url()。'custom / footarinvoice.jpg/>');
$ wm = base_url()。 定制/ Watermark.jpg;
$ pdf-> SetWatermarkImage($ wm);
$ pdf-> showWatermarkImage = true;
$ data ['main_content'] ='dwnld';
$ this-> load-> view('template',$ data);
$ html = $ this-> load-> view('template_pdf',$ data,true);
$ this-> load-> view('template_pdf',$ data,true);
$ pdf-> WriteHTML($ html);
$ pdf-> page = 0;
$ pdf-> state = 0;
$ pdf->输出($ pdfFilePath,D); b
$ b rel =nofollow noreferrer>
解决方案
$ pdf-> SetHTMLHeader('< img src ='。base_url()。'custom / Hederinvoice。 JPG/>');
$ pdf-> SetHTMLFooter('< img src =''。base_url()。'custom / footarinvoice.jpg/>');
$ wm = base_url()。 定制/ Watermark.png;
$ data ['main_content'] ='dwnld';
// $ this-> load-> view('template',$ data);
$ html = $ this-> load-> view('template_pdf',$ data,true);
$ this-> load-> view('template_pdf',$ data,true);
$ pdf-> AddPage('',// L - 横向,P - 纵向
'','','','',
5,// margin_left
5,//保证金权利
60,//保证金顶部
30,//保证金底部
0,//保证金头部
0); //页脚脚注
$ pdf-> WriteHTML($ html);
$ pdf->输出($ pdfFilePath,D);
Addpage用于在mpdf中创建页面并传递margin top,bottom的参数,然后我们得到正确的输出
I have generate one PDF
using mpdf
library in Codeigniter
.
I want to attache header image and footer image with proper margin, i have created one code but header and footer get overlapped please help me for this issue
thanks in advance
//controller
$this->load->library('m_pdf');
$param = '"","A4","","",0,0,100,0,6,3,"L"';
$pdf = $this->m_pdf->load($param);
// $pdf->useOddEven = true;
$pdf->SetHTMLHeader('<img src="' . base_url() . 'custom/Hederinvoice.jpg"/>');
$pdf->SetHTMLFooter('<img src="' . base_url() . 'custom/footarinvoice.jpg"/>');
$wm = base_url() . 'custom/Watermark.jpg';
$pdf->SetWatermarkImage($wm);
$pdf->showWatermarkImage = true;
$data['main_content'] = 'dwnld';
$this->load->view('template', $data);
$html = $this->load->view('template_pdf', $data, true);
$this->load->view('template_pdf', $data, true);
$pdf->WriteHTML($html);
$pdf->page = 0;
$pdf->state = 0;
$pdf->Output($pdfFilePath, "D");
解决方案 $pdf->SetHTMLHeader('<img src="' . base_url() . 'custom/Hederinvoice.jpg"/>');
$pdf->SetHTMLFooter('<img src="' . base_url() . 'custom/footarinvoice.jpg"/>');
$wm = base_url() . 'custom/Watermark.png';
$data['main_content'] = 'dwnld';
//$this->load->view('template', $data);
$html = $this->load->view('template_pdf', $data, true);
$this->load->view('template_pdf', $data, true);
$pdf->AddPage('', // L - landscape, P - portrait
'', '', '', '',
5, // margin_left
5, // margin right
60, // margin top
30, // margin bottom
0, // margin header
0); // margin footer
$pdf->WriteHTML($html);
$pdf->Output($pdfFilePath, "D");
Addpage for to creating page in mpdf and pass parameters of margin top,bottom then we get proper output
这篇关于我想使用mpdf在pdf中设置页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文