1
What am I doing
I’m rewriting a small barcode generation system using Laravel.
What went wrong
I’m instantiating the classes normally, but when I use the method $pdf->SetFont('Arial','B',$fontSize);
I get the message FPDF error: Undefined font: Helvetica B. As you can see in the screenshot below, the "font" folder is already included inside the library folder. I entered inside the library and searched for the method Setfont, and only changed the folder path, since the lib and font file is inside my directory.
My Code
I will leave only small parts of the code
<?php namespace App\Http\Controllers;
//Declaração de uso de elementos para layout, bibliotecas e depois model com bd
use View, Input, Validator, FPDF, eFPDF, BarcodeClass, BarcodeEAN, DB, App\Models\Barcode;
class HomeController extends Controller {
public function index() {
return view('frontend.home');
}
public function gerarPdf() {
//parte inicial do código
//Cria um novo PDF
$pdf = new eFPDF('P', 'pt');
//Modifica informações de visualização do PDF
$pdf->SetFont('Arial','B',$fontSize);
Within the FPDF.php class it has the method below that is called to import the fonts.
function _getfontpath()
{
if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'font/'))
define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
}
I believe this is the best solution;Solution in English
– Adriano Carvalho
@Adrianocarvalho Yes, he has a class that extends PDF :S, it is the way it is in this text.
– Allan Ramos
You even set the sources directory of the FPDF
define('FPDF_FONTPATH','font/');
? The class has no method constructor?– stderr