PHPackages                             hussampw/laravel-arabic-html - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. hussampw/laravel-arabic-html

ActiveLibrary[Templating &amp; Views](/categories/templating)

hussampw/laravel-arabic-html
============================

Convert laravel view to arabic html (pdf) by using ArPHP and dompdf with arabic fonts and text.

01PHP

Since Jan 30Pushed 1y agoCompare

[ Source](https://github.com/hussampw/laravel-arabic-html)[ Packagist](https://packagist.org/packages/hussampw/laravel-arabic-html)[ RSS](/packages/hussampw-laravel-arabic-html/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Convert laravel view to arabic html (pdf) using ArPHP and dompdf with arabic text
=================================================================================

[](#convert-laravel-view-to-arabic-html-pdf-using-arphp-and-dompdf-with-arabic-text)

To handle Arabic text issue in a more clean way with no need to hack dompdf script at all.

This package makes it easy to convert view blade to pdf using [laravel-dompdf](https://github.com/barryvdh/laravel-dompdf) and [Ar-PHP](https://github.com/khaled-alshamaa/ar-php).

قمنا بكتابة هذا الباكج لدعم اللغة العربية في مكتبة [laravel-dompdf](https://github.com/barryvdh/laravel-dompdf) من خلال استخدام [Ar-PHP](https://github.com/khaled-alshamaa/ar-php)سيقوم الباكج بتنزيل المكتبات المطلوبة في حال كانت غير موجودة دون الحاجة لتنزيلها كلاً على حده.

يوفر هذا الباكج حالياً دالة واحدة فقط وهي toArabicHTML() بالاضافة إلى انه يمكنك استخدام المكتبات الأصلية في تحويل أي محتوى إلى ملف pdf .

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Package Installation](#package-installation)
- [Usage](#usage)

Requirements
------------

[](#requirements)

- DOM extension
- MBString extension
- php-font-lib
- php-svg-lib

Note that some required dependencies may have further dependencies (notably php-svg-lib requires sabberworm/php-css-parser).

### Recommendations

[](#recommendations)

- OPcache (OPcache, XCache, APC, etc.): improves performance
- GD (for image processing)
- IMagick or GMagick extension: improves image processing performance

Installation
------------

[](#installation)

### Package Installation

[](#package-installation)

Install the package using composer:

```
composer require ab-alselwi/laravel-arabic-html
```

### Configuration

[](#configuration)

فقط هنا تحتاج للقيام باعداد المكتباات المرتبطة .

The defaults configuration settings are set in `config/dompdf.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:

```
    php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider"
```

ينصح بتحديد مجلد الخطوط في المسار storage\\fonts .

You need to setup font\_dir in config\\dompdf by copy fonts folder to storage\\fonts or any folder with read and write permissions. You should be carful when write css , and font . you can't use font-weight:number like font-weight:600 ; just use font-weight:bold.

بعض التنسيقات قد لا يتم دعمها في dompdf مثل font-weight مع القيم الرقمية بالاضافة للعديد من التنسيقات التي تعتمد على flex box , ولعرض رسالة خطأ في حال وجود أي تنسيقات غير مدعومة يمكنك تغيير اعدادات عرض الخطاء كما يلي :

'show\_warnings' =&gt; true , // Throw an Exception on warnings from dompdf

for more detials about dompdf settings :

-
-

Usage
-----

[](#usage)

To handle Arabic text issue in a more clean way with no need to hack dompdf script at all.We use View macro, so use view('your\_blade\_view\_name')-&gt;toArabicHTML() to support any content in Arabic . [dompdf/dompdf#712 (comment)](https://github.com/dompdf/dompdf/issues/712#issuecomment-650592099)

### function parameters :

[](#function-parameters-)

- $line\_length :int ,optional, default 100. max length in line.
- $hindo :bool, optional, default false. convert numbers in text to hindo.
- $forcertl :bool, optional, default false. force right to left document direction.

تسختدم الدالة دالة utf8Glyphs الموجودة في مكتبة Ar-PHP لذا يمكنك أن تقوم بتخصيص بارامترات هذه الدالة حيث :

- 1 - $line\_length : اختياري رقم - في حال وجود نصوص طويلة قد يتطلب منك تحديد كم حرفاً في السطر الواحد قمنا بتعديل القيمة الافتراضية من 50 الى 100 حرف .
- 2- $hindo : اختياري قيمة منطقية bool في حال رغبت في تحويل الأرقام الموجودة في المستند إلى أرقام هندية قمنا بتعديل القيمة الافتراضية إلى false حيث ستبقى الأرقام على حالها بألارقام العربية والتي تكتب في اللغة الانجليزية حالياُ
- 3- $forcertl : اختياري قيمة منطقية bool تتوافق القيمة الافتراضية مع الدالة الأصلية false حيث تشير إلى فرض تحويل اتجاه المستند من اليمين إلى اليسار

Example:

```
$html = view('invoice')->toArabicHTML();

$pdf = PDF::loadHTML($html)->output();

$headers = array(
    "Content-type" => "application/pdf",
);

// Create a stream response as a file download
return response()->streamDownload(
    fn () => print($pdf), // add the content to the stream
    "invoice.pdf", // the name of the file/stream
    $headers
);
```

هذا هو شكل ال view invoice.blade.php

```
DOCTYPE html>

    Arabic Invoice

        * {
            font-family: DejaVu Sans !important;
        }

        body {
            font-size: 16px;
            font-family: 'DejaVu Sans', 'Roboto', 'Montserrat', 'Open Sans', sans-serif;
            padding: 10px;
            margin: 10px;

            color: #777;
        }

        body {
            color: #777;
            text-align: right;
        }

        body h1 {

            margin-bottom: 0px;
            padding-bottom: 0px;
            color: #000;
        }

        body h3 {

            margin-top: 10px;
            margin-bottom: 20px;
            color: #555;
        }

        body a {
            color: #06f;
        }

        @page {
            size: a4;
            margin: 0;
            padding: 0;
        }

        .invoice-box table {
            direction: ltr;
            width: 100%;
            text-align: right;
            border: 1px solid;
            font-family: 'DejaVu Sans', 'Roboto', 'Montserrat', 'Open Sans', sans-serif;
        }

        .row {
            display: block;
            padding-left: 24;
            padding-right: 24;
            page-break-before: avoid;
            page-break-after: avoid;
        }

        .column {
            display: block;
            page-break-before: avoid;
            page-break-after: avoid;
        }

            بيانات باللغة العربية

    ان هذا عبارة عن قالب عادي
    ومن هنا قمنا بعرض قالب اعتيادي فقط كمثال توضيحي .

                                فاتورة #: 123
                                الانشاء : يناير 1, 2015
                                تاريخ : فبراير 1, 2015

                العنصر

                السعر

                تصميم موقع

                $300.00

                استضافة (3 أشهر )

                $75.00

                نطاق (1 عام )

                $10.00

                الإجمالي :

                $385.00

                انما نحن هنا نقوم بكتابة نصوص عربية فلما لا يكون هناك اخرى مما قد يحتم علينا أن نكتب أكثر.
                وعليه فإن السطر هذا يعتبر سطر جديد

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b10fe71a7364a1512fa4927f8de925ec71f21a8a0e7a5adf65ee304dc17db6e0?d=identicon)[hussampw](/maintainers/hussampw)

---

Top Contributors

[![Ab-Alselwi](https://avatars.githubusercontent.com/u/45919148?v=4)](https://github.com/Ab-Alselwi "Ab-Alselwi (16 commits)")[![hussampw](https://avatars.githubusercontent.com/u/126373519?v=4)](https://github.com/hussampw "hussampw (2 commits)")

### Embed Badge

![Health badge](/badges/hussampw-laravel-arabic-html/health.svg)

```
[![Health](https://phpackages.com/badges/hussampw-laravel-arabic-html/health.svg)](https://phpackages.com/packages/hussampw-laravel-arabic-html)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
