Download the PHP package mostafamoknaa/laravel-arabic-pdf without Composer

On this page you can find all versions of the php package mostafamoknaa/laravel-arabic-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-arabic-pdf

Laravel Arabic PDF

Tests Latest Version Total Downloads

Generate PDFs with correct Arabic text in Laravel.

dompdf, the most used PDF library in Laravel, has no Arabic support. The letters come out disconnected (م ح م د instead of محمد) and the words are reversed. This package fixes both, with no changes to your Blade views:

بالعربي: حزمة Laravel لإنشاء ملفات PDF باللغة العربية بشكل صحيح: الحروف متصلة، والكلمات بترتيبها الصحيح من اليمين لليسار، مع الحفاظ على الأرقام والكلمات الإنجليزية، ودعم الجداول والنصوص الطويلة.

Requirements

Installation

The service provider and the ArabicPdf / Arabic facades are registered automatically.

To publish the config file (optional):

Usage

1. Create a Blade view

Add dir="rtl" to <html> (or to any element) so text is right-aligned and tables go right to left.

2. Generate the PDF

All methods

Long paragraphs

dompdf wraps lines itself, without knowing about Arabic. A long paragraph would therefore show its last words on the first line. To avoid this, wrap long paragraphs at a number of characters with the data-arabic-wrap attribute:

Or set max_chars_per_line in config/arabic-pdf.php to apply it everywhere. Choose a value that fits the width of your column and font size. Short texts (titles, labels, table cells) don't need it.

Using only the text helpers

Already using barryvdh/laravel-dompdf or another library? Use the Arabic facade to fix the HTML or the text yourself:

Or the @arabic Blade directive (escaped output):

Don't use @arabic inside views that go through ArabicPdf::loadView(), since those are already fixed automatically. Fixing twice is safe but unnecessary.

Skipping elements

Add data-arabic-skip to keep an element's text as it is:

<script>, <style>, <textarea> and <svg> are always skipped.

Fonts

The font must contain the Arabic Presentation Forms glyphs (U+FB50–U+FDFF and U+FE70–U+FEFF). DejaVu Sans ships with dompdf, has them, and is the default font. To use another font, register it with @font-face (a TTF file inside your project):

Many modern web fonts only support Arabic through OpenType features and don't include these glyphs. If you see empty boxes or "?", your font is missing them, so try another font.

Configuration

How it works

  1. Your view is rendered to HTML and parsed with PHP's DOM extension.
  2. Each Arabic text node is shaped: letters are replaced by their contextual presentation forms (for example ب becomes ﺑ, ﺒ, ﺐ or ﺏ depending on its neighbours).
  3. The text is reordered from logical to visual order with the Unicode Bidirectional Algorithm. Arabic runs are reversed, while numbers and Latin runs keep their direction, and brackets are mirrored.
  4. Inline elements inside RTL paragraphs and table cells inside dir="rtl" are reordered too.
  5. The result is passed to dompdf, which just draws it left to right.

Testing

Contributing

Pull requests are welcome. Please add a test for any bug fix or new feature.

License

The MIT License (MIT). See LICENSE.md.


All versions of laravel-arabic-pdf with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-dom Version *
ext-mbstring Version *
dompdf/dompdf Version ^2.0|^3.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/view Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mostafamoknaa/laravel-arabic-pdf contains the following files

Loading the files please wait ...