What I'm doing
I'm rewriting a small bar code generation system using Laravel.
What went wrong
I'm instantiating classes normally, but when I use the $pdf->SetFont('Arial','B',$fontSize);
method I get the message FPDF error: Undefined font: helvetica B . As you can see in the image below, the "font" folder is already included inside the library folder. I went into the library and looked for the SetFont method, and just changed the folder path, since the lib e 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 class FPDF.php 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 : '';
}