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

v1.3.0 2025-12-04 13:27 UTC

This package is auto-updated.

Last update: 2025-12-05 10:36:52 UTC


README

ArPDF Logo

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:

  1. Place fonts inside a folder, e.g.:
    resources/fonts/
  2. Register them inside ArPDF.php (font bootstrap section)
  3. 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.