Reputation: 143
I’ve been rewriting a barcode generating system using Laravel.
I’m instancing the classes normally, but using the metod $pdf->SetFont('Arial','B',$fontSize);
I receive an error message FPDF error: Undefined font: helvetica B. As you can see below, the paste “font” is already included into the library paste.
<?php namespace App\Http\Controllers;
//Elements declaration of layout, libraries and model
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() {
//some code
//Creates a new PDF
$pdf = new eFPDF('P', 'pt');
//Modify PDF font
$pdf->SetFont('Arial','B',$fontSize);
Inside FPDF.php
function _getfontpath()
{
if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'font/'))
define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
}
Upvotes: 0
Views: 4255
Reputation: 143
Firtly, the getPath
method was being required however the define
wasn’t receiving the hole paste’s folder. Its dirname
wasn’t working so I switched to app_path().'/Libraries/FPDF/font/'
and, in the ending of the method, I’ve put exit;
after $pdf->Output
. If not, the browser would show the following characters:
%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x�e��N�0��} �R<��?W$@�g(�g^�� ��r���~��w&
Upvotes: 1