Laravel + DOMPDF - How do I count the number of pages in a report after downloading?

Asked

Viewed 282 times

0

I saw several examples on the Internet but nothing that I can adapt to my code or that works. Example in the footer wanted to display like this. Page:1/30, 2/30 and so on, man controller is like this:

return \PDF::loadView('RelatorioPSIConsultas', compact('Registros','Empresa'))
            ->setPaper('A4', 'landscape')
            //->stream('relatorio_alunos.pdf');
            ->download('Rel_Consultas_Psicologos.pdf');

My View:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Relatório de Consultas dos Psicólogos</title>
    <link href="{{asset('css/StyleRelatorios.css')}}" rel="stylesheet"> 
  </head>

  <body>
    <main>

    <h1  class="clearfix">
        @foreach ($Empresa as $cab)
        <small><span><img id="foto"  src="{{ $cab->emp_logo }}">

        </span>

        </small>
       {{ $cab->emp_rezao_social }}

        <div id="project">
          <div class="arrow"><div class="inner-arrow">Tel: {{ $cab->emp_tel }}</div></div>
          <div class="arrow"><div class="inner-arrow">E-mail: {{ $cab->emp_email }}</div></div>
          <div class="arrow"><div class="inner-arrow">Impresso em: {{ $cab->impresso }}</div></div>
        </div>
        <br>

        <span id="endereco">
        {{$cab->endereco}}
        </span>
        @endforeach
    </h1>
      <table class="tabela">
        <thead>
          <tr id="DescrColunas">
            <td>Prontuário</td>
            <td>Paciente</td>
            <td>Tipo de Atendimento</td>
            <td>Resp. Atendimento</td>
            <td>Atendimento</td>
          </tr>
        </thead>
        <tbody>
            @foreach ($Registros as $dados)
                <tr>
                    <td class="Menorcolumn">{{ $dados->pac_prontuario }}</td>
                    <td>{{ $dados->pac_nome_paciente }}</td>
                    <td>{{ $dados->ate_descricao }}</td>
                    <td>{{ $dados->psi_nome }}</td>
                    <td class="Menorcolumn">{{ $dados->dtAtendimento }}</td>

                </tr>
            @endforeach
        </tbody>
      </table>

    </main>
    <footer>

    </footer>
  </body>
</html>
  • 1

    Possible duplicate of Page number with DOMPDF and LARAVEL

  • can display page numbers, but I want it to be at the bottom of the page. how do I do that? my code.. <script type="text/php"> if ( isset($pdf) ) { $font = $fontMetrics->get_font("Helvetica", "Bold"); $pdf->page_text(90, 30, "Page: {PAGE_NUM} of {PAGE_COUNT}", $, 20, array(0,0,0)); } </script>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.