Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
¿Cómo puedo personalizar la fuente y la página en laravel dompdf?

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?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!