For my project I have to generate a PDF file. Stackoverflow told me to use FPDF. So, I followed the tutorial but it doesn't seem to work.
public function makePdf(Request $request){
require('fpdf181/fpdf.php');
$pdf = new FPDF('p', 'mm', 'A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
}
This is completely following the tutorial but it doesn't work.
I tried this as well:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
require('fpdf181/fpdf.php');
But than again, I get the same error.
change this:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
require('fpdf181/fpdf.php');
to this:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use FPDF;
because of PSR-4 autoloading namespaces you dont have to include it explicitly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With