samedi 19 décembre 2015

UTF-8 Encoding with Dompdf

I've seen a lot of people asked about encoding problems with dompdf but none of solutions given is helped me.

this is my controller

 $time = time();
$output = \PDF::loadView('pdf-templates.studentlist',array('users' => $users))
->setPaper('a4')
->setOrientation('landscape')
->setWarnings(false);


        return  $output->stream($time.".pdf", array("Attachment" => 0));

and this is my view file

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <style>   

    body {font-family: firefly, verdana, sans-serif; font-size:15pt;}
    table {width:100%; border-collapse:collapse; border:1px solid #CCC;}
    td {padding:5px; border:1px solid #CCC; border-width:1px 0;}
  </style>
</head>
<body>

    <script type='text/php'>
    if ( isset($pdf) ) { 
    $font = Font_Metrics::get_font('DejaVu Sans', 'normal');
      $size = 9;


      $y = $pdf->get_height() - 24;
      $x = ($pdf->get_width() / 2) - Font_Metrics::get_text_width('1/1', $font, $size);
      $pdf->page_text($x, $y, '{PAGE_NUM}/{PAGE_COUNT}', $font, $size);


      $ust_y = 20;
      $ust_x = ($pdf->get_width() / 2) - Font_Metrics::get_text_width('1/1', $font, $size);
      $pdf->page_text($ust_x, $ust_y, '{PAGE_NUM}/{PAGE_COUNT}', $font, $size);
    } 



  </script>




  <table  >
    <tr>

      <th>">Username   ııı şşş ççç ğğğ </th>


    </tr>

    @foreach($users as $user)
    <tr>

          <td >{{ $user->name}}</td>

     </tr>
  @endforeach 




  </table>

</body>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire