我想用mpdf设置页眉和页脚的pdf格式

时间:2022-10-20 20:46:21

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

我在Codeigniter中使用mpdf库生成了一个PDF。我想要配页眉图像和页脚图像,我已经创建了一个代码,但是页眉和页脚重叠了,请提前帮助我解决这个问题,谢谢

//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");

我想用mpdf设置页眉和页脚的pdf格式

1 个解决方案

#1


9  

 $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中创建页面添加页并传递页边顶部、底部的参数,然后我们得到适当的输出

#1


9  

 $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中创建页面添加页并传递页边顶部、底部的参数,然后我们得到适当的输出