Support the ongoing development of Laravel.io →
Installation Configuration Packages

I follow this : http://stackoverflow.com/questions/19983610/how-to-get-page-number-on-dompdf-pdf-when-using-view

I add $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);

It's not working too

Note :

I using barryvdh/laravel-dompdf": "^0.7.0" (v0.7)

Is there any people who can help to me?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

moschel26 moschel26 Joined 21 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.