Obtengo de aquí: https://github.com/barryvdh/laravel-dompdf
Mi controlador es así:
public function listdata() { $pdf=PDF::loadView('print_tests.test_pdf'); $pdf->setPaper('L', 'landscape'); return $pdf->stream('test_pdf.pdf'); }Mi vista es así:
<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>Yo uso esto :
"barryvdh/laravel-dompdf": "^0.7.0",
Cuando se ejecuta, la fuente no es Arial y la página no se muestra.
¿Cómo puedo resolverlo?
intente en laravel 5.5 arriba .
1. Primero descargue la fuente que desea agregar (o configurar) como extensión .ttf
2.almacene dentro de la carpeta de almacenamiento de laravel como este storage/fonts/yourfont.ttf
3.Use las reglas CSS @font-face dentro de su hoja.
4.por ejemplo, cree un archivo sample.blade.php como este
<html> <head> <meta http-equiv="Content-Type" content="charset=utf-8" /> <style type="text/css"> @font-face { font-family: 'yourfont'; //you can set your custom name also here.. src: url({{ storage_path('fonts/yourfont.ttf') }}) format('truetype'); font-weight: 400; // use the matching font-weight here ( 100, 200, 300, 400, etc). font-style: normal; // use the matching font-style here } body{ font-family: "yourfont", //set your font name u can set custom font name also which u set in @font-face css rule </style> </head> <body> Check your font is working or not... </body> </html>