php - add image at header & footer on every page of pdf using dompdf -
i trying create pdf file using dompdf.
want show header , footer images on every page of pdf, problem in html know that, it's large html code googled other solution used here https://github.com/dompdf/dompdf/issues/807.
this code fine textual header , footer problem @ adding image tried best no use , getting error "call undefined method cpdf_adapter::page_script() in filepathname.php".
here code of generating pdf
$dompdf = new dompdf(); $dompdf->load_html($message2); $dompdf->set_paper('a4','portrait'); $dompdf->render(); $canvas = $dompdf->get_canvas(); //for header $header = $canvas->open_object(); $font = font_metrics::get_font("helvetica", "bold"); $date = date("y-m-d h:i:s"); $canvas->page_text(35, 25, "hivedesk screenshot report", $font, 8, array(0, 0, 0)); $canvas->page_text(490, 25, "hivedesk.com", $font, 8, array(0, 0, 0)); $canvas->close_object(); $canvas->add_object($header, "all"); //for footer $footer = $canvas->open_object(); $font = font_metrics::get_font("helvetica", "bold"); $date = date("y-m-d h:i:s"); $canvas->page_text(250, 800, "page: {page_num} of {page_count}", $font, 8, array(0, 0, 0)); $canvas->page_script('$image = '.$header_image1.'; $pdf->image($image, 400, 25, 100, 25); '); $canvas->close_object(); $canvas->add_object($footer, "all"); $output = $dompdf->output(); $filename ="pdf/".time().".pdf"; file_put_contents("$filename",$output);
note: $message2 contains html content.
can please give me solution?
thanks in advance.
Comments
Post a Comment