Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

How to export utf-8 in laravel 5.8

I installed dompdf in my project. I want to export auth()->user() in laravel and I have a problem like this image.

pdf

Controller.php

use Barryvdh\DomPDF\Facade as PDF;

public function PDF()
{
    $pdf = PDF::loadView('load-pdf');
    $pdf->set_option('font-family', 'Tahoma');
    return $pdf->download('user.pdf');
}

load-pdf.blade.php

<!doctype html>
<html lang="fa" dir="rtl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('css/bootstrap.min-rtl.css') }}">
    <style>
        * {
            font-family: Tahoma;
        }
    </style>
</head>
<body>
<div class="row">
    <div class="col-md-2">
        <img src="{{ asset('images/users/'.auth()->user()->image) }}" class="rounded-circle w-25">
    </div>
    <div class="col-md-10">
        <div class="row">
            <div class="col-md-4">
                <div>نام:</div>
                <div>{{ auth()->user()->first_name }}</div>
            </div>
            <div class="col-md-4">
                <div>نام خانوادگی:</div>
                <div>{{ auth()->user()->last_name }}</div>
            </div>
            <div class="col-md-4">
                <div>عنوان شغلی رزومه:</div>
                <div>{{ auth()->user()->job_title }}</div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
0 likes
4 replies
shahr's avatar
Level 10

I installed this package

pdf

shahr's avatar
Level 10

Does anyone answer my question?

margeghafie's avatar

I find out that the best way after try much times is to use vatttan/apdf package. Documentation is in github: vatttanweb/APdf

Please or to participate in this conversation.