1

I get from here : https://github.com/barryvdh/laravel-dompdf

My controller is like this :

public function listdata()
{
    $pdf=PDF::loadView('print_tests.test_pdf');
    $pdf->setPaper('L', 'landscape');
    return $pdf->stream('test_pdf.pdf');
}

My view is like this :

<script type="text/php">

    if ( isset($pdf) ) {
        $x = 72;
        $y = 18;
        $text = "{PAGE_NUM} of {PAGE_COUNT}";
        $font = $fontMetrics->get_font("Arial", "bold");
        $size = 6;
        $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>

I use this :

"barryvdh/laravel-dompdf": "^0.8.0",

When executed, the page number not display.

How can I solve it?

samuel toh
  • 6,836
  • 21
  • 71
  • 108
  • Have you loaded the "Arial" font into Dompdf? If not then you should try using "Helvetica" instead, or the more generic "sans-serif". – BrianS May 08 '17 at 21:14
  • @BrianS. No. Because I want to use Arial. I had change it to Helvetica. But the page number not display – samuel toh May 08 '17 at 22:15
  • Is there no one to help? I've made some questions, but no answers help – samuel toh May 09 '17 at 02:29
  • Are you saying the page number doesn't display when you using Helvetica? – BrianS May 25 '17 at 22:18
  • @BrianS, No. When I use arial, it also does not work – samuel toh May 26 '17 at 00:39
  • It _should_ work when using Helvetica as that's a core PDF font. Also important, make sure your embedded script is contained inside the `` element otherwise Dompdf will ignore it. – BrianS May 26 '17 at 19:33
  • Note that for version >= 0.7, you should be using [Dennis Ameling's solution](https://stackoverflow.com/a/38788676/5727643). – Amin NAIRI Oct 25 '17 at 08:28

1 Answers1

1

You've used <script> tag with PHP type,

its just an other way to tell the parser that the code between the tags is in PHP.

However it is not recommended to use, because some browsers may not translate it correctly. Use the normal PHP code.

<?php ?>
Bhaumik Pandhi
  • 2,655
  • 2
  • 21
  • 38