laravel-dompdf 添加页码

梁祯
2023-12-01

Controller

$pdf = PDF::loadview('contractpdf');

$pdf->setOptions(['isPhpEnabled'=> true]);

$pdf->setPaper('L', 'landscape');

return $pdf->setPaper('a4')->stream();

 

blade.php

<script type="text/php">

if (isset($pdf)) {

$x = 250;

$y = 800;

$text = "第 {PAGE_NUM} 页 共 {PAGE_COUNT} 页";

$font = null;

$size = 14;

$color = array(0,0,0);

$word_space = 0.0; // default

$char_space = 0.0; // default

$angle = 0.0; // default

$pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);

}

</script>

 

 类似资料: