[英]Call to undefined method Barryvdh\DomPDF\PDF::setOptions() (laravel 5.3)
I follow this : How to get page number on dompdf PDF when using "view" 我遵循这一点: 使用“视图”时如何在dompdf PDF上获取页码
I add $pdf->setOptions('isPhpEnabled', true);
我添加
$pdf->setOptions('isPhpEnabled', true);
is like this : 就像这样:
public function listdata()
{
$data = User::all();
$pdf=PDF::loadView('print_tests.test_pdf', ['data' => $data]);
$pdf->setOptions('isPhpEnabled', true);
$pdf->setPaper('L', 'landscape');
return $pdf->stream('test_pdf.pdf');
}
In body (View) I add like this : 在正文(视图)中,我这样添加:
<script type="text/php">
if ( isset($pdf) ) {
$x = 72;
$y = 18;
$text = "{PAGE_NUM} of {PAGE_COUNT}";
$font = $fontMetrics->get_font("helvetica", "bold");
$size = 6;
$color = array(255,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>
There is exist error like this : 存在这样的错误:
FatalThrowableError in PrintTestController.php line 21: Call to undefined method Barryvdh\DomPDF\PDF::setOptions()
I try change to be like ths : $pdf->set_options('isPhpEnabled', true);
我尝试更改为像这样:
$pdf->set_options('isPhpEnabled', true);
It's not working too 也没用
Note : 注意 :
I using barryvdh/laravel-dompdf": "^0.7.0" (v0.7) 我使用barryvdh / laravel-dompdf“:” ^ 0.7.0“(v0.7)
Is there any people who can help to me? 有没有人可以帮助我?
UPDATE 更新
I try again like this : 我像这样再次尝试:
use Dompdf\Dompdf;
public function listdata()
{
$data = User::all();
$pdf = new Dompdf();
$pdf->set_option("isPhpEnabled", true);
$pdf=PDF::loadView('print_tests.test_pdf', ['data' => $data]);
$pdf->setPaper('L', 'landscape');
return $pdf->stream('test_pdf.pdf');
}
No error, but page number invisible 没有错误,但页码不可见
You may want to stop using 3 1/2-year old questions and answers, and start using the documentation provided by the developer ! 您可能要停止使用3 1/2年的问题和答案,而开始使用开发人员提供的文档 !
There is a function Dompdf::set_option()
you are probably looking for. 您可能正在寻找一个函数
Dompdf::set_option()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.