Adding header and footer with page number in dompdf

后端 未结 3 1265
灰色年华
灰色年华 2020-12-31 20:09

I am working with Codeigniter and I successfully implemented dompdf for generating PDF files. Now I have issues on adding a header and footer in generated PDF.

Here

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-31 20:43

    I have also tried to add PHP code into the html but have never got a chance to make it work. here is the complete inline code which I guarantee works:

    require_once("dompdf_config.inc.php");
    $html ='
            
            

    Hello Hello

    Hello Hello 2

    Hello Hello 3

    '; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $canvas = $dompdf->get_canvas(); $font = Font_Metrics::get_font("helvetica", "bold"); $canvas->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0)); $dompdf->stream("my_pdf.pdf", array("Attachment" => 0)); ?>

提交回复
热议问题