PHPackages                             rmscms/pdf - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. rmscms/pdf

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

rmscms/pdf
==========

A Pdf package for Laravel applications

v1.1(9mo ago)01341MITBlade

Since Aug 14Pushed 9mo agoCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

RMS PDF Package
===============

[](#rms-pdf-package)

A Laravel package for generating PDF invoices with full RTL support, specifically designed for Persian (Farsi) language invoices using the mPDF library.

Features
--------

[](#features)

- Generates PDF invoices with complete RTL and Persian font support (Vazir font by default).
- Structured data management using `Seller`, `Buyer`, `Bank`, `Product`, and `Invoice` classes.
- Customizable invoice templates using Blade views.
- Configurable default font and theme via a configuration file.
- Seamless integration with Laravel 12.
- Supports dynamic data injection for invoices.
- Includes a test route for easy development and testing.

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 12.0
- mPDF &gt;= 8.2

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

[](#installation)

1. **Install via Composer**:

    ```
    composer require rmscms/pdf
    ```
2. **Publish Assets**: Publish fonts, views, and configuration to your project:

    ```
    php artisan vendor:publish --tag=rms-pdf-fonts
    php artisan vendor:publish --tag=rms-pdf-views
    php artisan vendor:publish --tag=rms-pdf-config
    ```

    This copies:

    - Vazir fonts to `public/vendor/rms-pdf/fonts`.
    - Blade templates to `resources/views/vendor/rms-pdf`.
    - Configuration file to `config/rms-pdf.php`.
3. **Verify Dependencies**: The `mpdf/mpdf:^8.2` dependency is automatically included via the package's `composer.json`.

Configuration
-------------

[](#configuration)

The package uses the Vazir font and `elegant` template by default for Persian text. These can be customized in the `config/rms-pdf.php` file:

```
return [
    'default_font' => 'vazir',
    'default_theme' => 'elegant',
    'fontdata' => [
        'vazir' => [
            'R' => 'Vazir.ttf',
            'B' => 'Vazir-Bold.ttf',
            'useOTL' => 0xFF,
            'useKashida' => 75,
        ],
    ],
];
```

### Adding Custom Fonts

[](#adding-custom-fonts)

To use a different font (e.g., `IRANSans`), place the `.ttf` files in your project's `public/vendor/rms-pdf/fonts` after publishing, and update `config/rms-pdf.php`:

```
return [
    'default_font' => 'iransans',
    'default_theme' => 'elegant',
    'fontdata' => [
        'iransans' => [
            'R' => 'IRANSans.ttf',
            'B' => 'IRANSans-Bold.ttf',
            'useOTL' => 0xFF,
            'useKashida' => 75,
        ],
    ],
];
```

Run the publish command to ensure fonts are available:

```
php artisan vendor:publish --tag=rms-pdf-fonts
```

Usage
-----

[](#usage)

The package provides a `PDF` facade to generate invoices. Data is structured using the `Seller`, `Buyer`, `Bank`, `Product`, and `Invoice` classes.

### Classes

[](#classes)

- **Seller**: Manages seller information and bank details.
    - Properties: `company`, `address`, `postal_code`, `phone`, `bank` (instance of `Bank`).
- **Bank**: Manages bank account details.
    - Properties: `account_holder`, `card_number`, `sheba`.
- **Buyer**: Manages buyer information.
    - Properties: `name`, `address`, `postal_code`, `phone`.
- **Product**: Represents a single invoice item.
    - Properties: `description`, `quantity`, `unit_price`, `total`.
- **Invoice**: Manages invoice details and a collection of products.
    - Properties: `title`, `subtitle`, `invoice_number`, `invoice_date`, `reference`, `total_items`, `postage_cost`, `discount`, `discount_note`, `final_amount`, `products` (array of `Product` objects), `footer_left`, `footer_right`.

### Creating a Custom Template

[](#creating-a-custom-template)

To create a custom invoice template, follow these steps:

1. **Create a Blade File**: Place your template in `resources/views/vendor/rms-pdf` (after publishing views). Use the `elegant.blade.php` template as a reference:
    - Structure your HTML with `lang="fa" dir="rtl"` for Persian support.
    - Use `unicode-bidi: embed` in CSS for proper text rendering.
    - Access data via `$seller`, `$buyer`, and `$invoice` objects (e.g., `$seller->company`, `$invoice->products`).
2. **Style with CSS**:
    - Use mPDF-compatible CSS properties like `border`, `border-radius`, `flex`, `grid`, `padding`, `margin`.
    - Avoid complex CSS (e.g., `box-shadow`, `gradient`) as mPDF has limited support.
    - Ensure `font-family` matches the configured font (e.g., `Vazir` or `IRANSans`) and `direction: rtl` for Persian text.
3. **Publish the Template**: If you add templates to the package source, they will be published with: ```
    php artisan vendor:publish --tag=rms-pdf-views
    ```
4. **Set Default Theme**: Update `config/rms-pdf.php` to use your custom template: ```
    'default_theme' => 'your-custom-theme',
    ```

### Route Configuration

[](#route-configuration)

The package includes a test route in `routes/pdf.php` for development purposes. To use it, ensure your application's `routes/web.php` includes:

```
// routes/web.php
use RMS\PDF\Http\Controllers\PdfController;

Route::get('/rms-pdf-test', [PdfController::class, 'generate']);
```

### Testing

[](#testing)

To test the package:

1. Publish fonts, views, and configuration: ```
    php artisan vendor:publish --tag=rms-pdf-fonts
    php artisan vendor:publish --tag=rms-pdf-views
    php artisan vendor:publish --tag=rms-pdf-config
    ```
2. Visit `/rms-pdf-test` in your browser to download the PDF generated by the package's test controller (`RMS\PDF\Http\Controllers\PdfController`).
3. Verify that:
    - Persian text (e.g., "ریال", "فاکتور فروش") is rendered correctly with connected characters.
    - Styles (e.g., `grid`, `flex`, `border`, `double`, `dotted`, `border-radius`) are applied properly.
    - Data from `Seller`, `Buyer`, `Bank`, and `Invoice` classes is displayed correctly.

### Troubleshooting

[](#troubleshooting)

- **Text Rendering Issues**: Ensure the font files (e.g., `Vazir.ttf`, `Vazir-Bold.ttf` or `IRANSans.ttf`, `IRANSans-Bold.ttf`) are in `public/vendor/rms-pdf/fonts` and are from a reliable source (e.g., [Vazir GitHub](https://github.com/rastikerdar/vazir-font/releases)).
- **Class Not Found Errors**: Run `composer dump-autoload` in your project root to refresh the autoloader.
- **Styling Issues**: If styles like `border-radius` or `grid` don't render correctly, simplify the CSS or check mPDF documentation for supported properties.

### Contributing

[](#contributing)

Contributions are welcome! Please submit issues or pull requests to the [GitHub repository](https://github.com/rmscms/pdf).

### License

[](#license)

This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance58

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

276d ago

### Community

Maintainers

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

---

Top Contributors

[![spyp](https://avatars.githubusercontent.com/u/15471788?v=4)](https://github.com/spyp "spyp (8 commits)")

### Embed Badge

![Health badge](/badges/rmscms-pdf/health.svg)

```
[![Health](https://phpackages.com/badges/rmscms-pdf/health.svg)](https://phpackages.com/packages/rmscms-pdf)
```

###  Alternatives

[carlos-meneses/laravel-mpdf

Laravel Mpdf: Using Mpdf in Laravel to generate Pdfs.

4403.1M7](/packages/carlos-meneses-laravel-mpdf)[kartik-v/yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.

1605.5M84](/packages/kartik-v-yii2-mpdf)[contributte/pdf

Pdf response extension for Nette Framework

43967.8k2](/packages/contributte-pdf)[robregonm/yii2-pdf

Yii 2 PDF Response Formatter

4647.5k1](/packages/robregonm-yii2-pdf)[jkuchar/pdfresponse

PdfResponse is wrapper of mPDF for Nette.

10329.4k](/packages/jkuchar-pdfresponse)[famelo/pdf

Provides a quick and simple way to generate a PDF from a Fluid Template through the MPDF library

1872.8k](/packages/famelo-pdf)

PHPackages © 2026

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