baidouabdellah / laravel-arpdf
Generate Arabic-friendly PDFs in Laravel (wrapper around mPDF)
Installs: 115
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 3
Open Issues: 0
pkg:composer/baidouabdellah/laravel-arpdf
Requires
- php: ^8.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- mpdf/mpdf: ^8.2
README
Laravel ArPDF
A Laravel package for generating PDF files with full Arabic and English support, including UTF-8, RTL, and custom font integration, using the powerful mPDF engine โ all without relying on external services.
๐ Features
- โ๏ธ Fully supports Arabic, RTL, UTF-8, and mixed languages
- โ๏ธ Clean & simple Laravel-style API
- โ๏ธ Includes Facade + Auto-Discovery
- โ๏ธ Works with Laravel 8, 9, 10, 11, 12
- โ๏ธ Supports custom Arabic fonts (Cairo, Amiri, etc.)
- โ๏ธ High-quality rendering powered by mPDF
- โ๏ธ Save, download, or stream PDFs from your controller
๐ฆ Installation
Install the package via Composer:
composer require baidouabdellah/laravel-arpdf
โ Laravel 8+
No configuration is required โ Laravel automatically discovers the package.
โ For Laravel < 8 (Manual Registration)
Add the service provider to config/app.php:
'providers' => [ Baidouabdellah\LaravelArpdf\ArPDFServiceProvider::class, ],
Publish Configuration
php artisan vendor:publish --provider="Baidouabdellah\LaravelArpdf\ArPDFServiceProvider"
This allows customizing fonts, default direction (RTL/LTR), and mPDF settings.
๐งช Usage Example
Controller Demo
use Baidouabdellah\LaravelArpdf\Facades\ArPDF; public function generatePdf() { return ArPDF::loadView('arpdf-test', [ 'title' => 'ุงููุบุฉ ุงูุฑุนุจูุฉ ูู ุงูุนููุงู', 'message' => 'ูู ูุฏุฌู ููุต ุนุฑุจู ู ู ุงููู ูู ุงูู ุงููุณุงุฑ', ])->stream('view-test.pdf'); }
๐ Blade View Example
Create a view such as:
resources/views/pdf/invoice.blade.php
<!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <style> body { font-family: 'cairo'; direction: rtl; text-align: right; } </style> </head> <body> <h1>{{ $title }}</h1> <p>ู ุฑุญุจุง ุจู ูู ูุธุงู ุงูููุงุชูุฑ.</p> </body> </html>
Render and export:
$html = view('pdf.invoice', [ 'title' => 'ูุงุชูุฑุฉ ุฑูู 123' ])->render(); return ArPDF::loadHTML($html)->download('invoice-123.pdf');
๐ค Custom Arabic Fonts
mPDF supports custom fonts such as Cairo, Amiri, Scheherazade, etc.
To use your own fonts:
- Place fonts inside a folder, e.g.:
resources/fonts/ - Register them inside
ArPDF.php(font bootstrap section) - Use them in CSS:
body { font-family: 'cairo'; }
๐ Support
If you encounter any issue, feel free to open a ticket here:
๐ https://github.com/baidou5/laravel-arpdf/issues
๐ค Author
Abdellah Baidou
๐ฑ Phone: +212 661-176711
๐ง Email: baidou.abd@gmail.com
๐ License
This package is licensed under the MIT License.
See the LICENSE file for more information.
