baidouabdellah/laravel-arpdf
最新稳定版本:v1.3.0
Composer 安装命令:
composer require baidouabdellah/laravel-arpdf
包简介
Generate Arabic-friendly PDFs in Laravel (wrapper around mPDF)
README 文档
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.
统计信息
- 总下载量: 136
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-21
