I am using FPDI to generate PDFs from a template.pdf file in a Laravel 5 project, but I am having issues with UTF-8 names since FDPI does not support the encoding natively.
I did a lot of searching and tFPDF and TCPDF seem to be the most used solutions for this issue, though I cannot seem to successfully integrate any of them in my laravel application.
I have already referred to these links with no luck:
FPDI with tFPDF: https://www.setasign.com/products/fpdi/demos/legacy-v1/
FPDI with TCPDF: https://www.setasign.com/products/fpdi/demos/tcpdf-demo/
This is the PHP function I am using inside my laravel controller.
public static function generateCertificate($firstname, $fullname, $course_name, $level, $date, $output, $email = null, $certificate_link = null)
{
$fullname = stripslashes($fullname);
$fullname = 'Witaj świecie'; //Added to debug issue
//Start PDF Generation
$pdf = new \setasign\Fpdi\Fpdi();
//Set Template
$path = app()->publicpath().'/assets/templates/examination_level100_certificate.pdf';
$pageCount = $pdf->setSourceFile($path);
$template = $pdf->importPage(1);
$size = $pdf->getTemplateSize($template);
$pdf->addPage();
$pdf->useTemplate($template, null, null, null, null, true);
//Add the fonts
$pdf->AddFont('Myriad-pro', '', 'myriad-pro-regular.php');
$pdf->AddFont('Myriad-pro-semibold', '', 'myriad-pro-semibold.php');
//Set Title
$pdf->SetTitle($fullname.' - '.str_replace(' - ', ' ', $course_name).' - Certicifate');
//Add User Name
$pdf->SetFont('Arial', '', 40);
$pdf->SetTextColor(67, 156, 209);
$pdf->SetY(164);
$pdf->Cell(0, 20, $fullname, 0, 1, 'C');
$pdf->Output('I', str_slug($fullname.'-'.$course_name).'.pdf', true);
}