PHPackages                             deecodek/larapdfx - 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. deecodek/larapdfx

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

deecodek/larapdfx
=================

Modern, production-ready PDF generation for Laravel with full CSS3 support, perfect rendering, and advanced features.

v1.0.1(5mo ago)06MITPHPPHP ^8.2|^8.3|^8.4CI failing

Since Nov 30Pushed 5mo agoCompare

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

READMEChangelogDependencies (8)Versions (2)Used By (0)

LaraPDFX
========

[](#larapdfx)

[![Latest Version](https://camo.githubusercontent.com/af1eeaec15b36fb9daa984ddf1165a3c2a66ed06679b62a9ceed384effb27b19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/af1eeaec15b36fb9daa984ddf1165a3c2a66ed06679b62a9ceed384effb27b19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/988a57ebd9d29a1981c15efc7a461f6d475e22cb2b221abc1256c862b425dfee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/988a57ebd9d29a1981c15efc7a461f6d475e22cb2b221abc1256c862b425dfee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/de44163cd19e9fb7137135a4123260a7f34f215e8e572d375448462afbf33f4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/de44163cd19e9fb7137135a4123260a7f34f215e8e572d375448462afbf33f4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)[![PHP Version](https://camo.githubusercontent.com/80038a9f65f5297094dbb19ed993062c094b398d15283bd36d08ed6cc248780f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/80038a9f65f5297094dbb19ed993062c094b398d15283bd36d08ed6cc248780f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646565636f64656b2f6c617261706466782e7376673f7374796c653d666c61742d737175617265)

**Modern, production-ready PDF generation for Laravel with full CSS3 support, perfect rendering, and advanced features.**

LaraPDFX solves all the pain points of existing PDF libraries by using Chrome headless rendering engine, giving you pixel-perfect PDFs with modern CSS support including Flexbox, Grid, and all CSS3 features.

---

🎯 Why LaraPDFX?
---------------

[](#-why-larapdfx)

### Problems with Existing Solutions (DomPDF, TCPDF, etc.):

[](#problems-with-existing-solutions-dompdf-tcpdf-etc)

❌ Only CSS 2.1 support - no modern CSS
❌ Slow performance &amp; memory issues
❌ Poor font rendering &amp; RTL language support
❌ Image handling problems
❌ No Flexbox or Grid support
❌ Bootstrap/Tailwind CSS incompatible
❌ Complex table layouts break

### ✨ LaraPDFX Advantages:

[](#-larapdfx-advantages)

✅ **Full CSS3 support** - Flexbox, Grid, modern properties
✅ **Perfect rendering** - Chrome engine ensures pixel-perfect output
✅ **Fast &amp; efficient** - Optimized memory usage
✅ **Modern frameworks** - Works with Bootstrap, Tailwind, any CSS
✅ **RTL languages** - Perfect Arabic, Hebrew, Persian support
✅ **Custom fonts** - All web fonts work flawlessly
✅ **Advanced features** - Encryption, watermarks, metadata
✅ **Production ready** - Tested and battle-proven

---

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.x or 11.x
- Chrome/Chromium installed on your system

---

🚀 Installation
--------------

[](#-installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require deecodek/larapdfx
```

### Step 2: Install Chrome/Chromium

[](#step-2-install-chromechromium)

**Ubuntu/Debian:**

```
sudo apt update
sudo apt install chromium-browser
```

**Alpine Linux (Docker):**

```
apk add --no-cache chromium
```

**macOS:**

```
brew install --cask google-chrome
```

**Windows:**Download from

### Step 3: Publish Configuration

[](#step-3-publish-configuration)

```
php artisan larapdfx:install
```

This will:

- Publish configuration file to `config/larapdfx.php`
- Check for Chrome installation
- Guide you through setup

### Step 4: Test Installation

[](#step-4-test-installation)

```
php artisan larapdfx:test
```

This generates a test PDF at `storage/app/test.pdf` to verify everything works.

---

📖 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

```
use Deecodek\LaraPDFX\Facades\PDF;

// Generate from Blade view
return PDF::view('invoice', ['data' => $data])
    ->download('invoice.pdf');

// Generate from HTML string
$html = 'Hello World';
return PDF::html($html)
    ->stream('document.pdf');

// Generate from URL
return PDF::url('https://example.com')
    ->download('page.pdf');
```

### Save to File

[](#save-to-file)

```
PDF::view('report', $data)
    ->save(storage_path('app/reports/report.pdf'));

// Or use storage disk
PDF::view('invoice', $data)
    ->save(storage_path('app/public/invoice.pdf'));
```

### Download PDF

[](#download-pdf)

```
// Direct download
return PDF::view('invoice', $data)
    ->download('invoice.pdf');
```

### Stream PDF (Display in Browser)

[](#stream-pdf-display-in-browser)

```
// Display inline in browser
return PDF::view('document', $data)
    ->stream('document.pdf');
```

### Base64 Encoding

[](#base64-encoding)

```
$base64 = PDF::view('report', $data)->base64();

// Use in email or API response
return response()->json([
    'pdf' => $base64
]);
```

---

🎨 Page Settings
---------------

[](#-page-settings)

### Paper Size

[](#paper-size)

```
// Predefined formats
PDF::view('invoice', $data)
    ->format('A4')  // A4, A3, A5, Letter, Legal, Tabloid, Ledger
    ->download();

// Or use shortcuts
PDF::view('invoice', $data)->a4()->download();
PDF::view('invoice', $data)->letter()->download();
PDF::view('invoice', $data)->legal()->download();

// Custom size (in millimeters)
PDF::view('invoice', $data)
    ->paperSize(210, 297)  // Custom width x height
    ->download();
```

### Orientation

[](#orientation)

```
// Landscape
PDF::view('report', $data)
    ->landscape()
    ->download();

// Portrait (default)
PDF::view('report', $data)
    ->portrait()
    ->download();

// Or use string
PDF::view('report', $data)
    ->orientation('landscape')
    ->download();
```

### Margins

[](#margins)

```
// All sides (in millimeters)
PDF::view('document', $data)
    ->margins(20)  // 20mm all sides
    ->download();

// Top/Right/Bottom/Left
PDF::view('document', $data)
    ->margins(10, 15, 10, 15)
    ->download();

// Using array
PDF::view('document', $data)
    ->margins([
        'top' => 10,
        'right' => 15,
        'bottom' => 10,
        'left' => 15,
    ])
    ->download();
```

### Scale

[](#scale)

```
// Scale the rendering (0.1 to 2.0)
PDF::view('document', $data)
    ->scale(0.8)  // 80% scale
    ->download();
```

---

📄 Headers &amp; Footers
-----------------------

[](#-headers--footers)

### Simple Footer with Page Numbers

[](#simple-footer-with-page-numbers)

```
PDF::view('report', $data)
    ->footerWithPageNumbers()
    ->download();
```

### Custom Header

[](#custom-header)

```
$header = 'Company Name';

PDF::view('invoice', $data)
    ->header($header)
    ->download();
```

### Custom Footer

[](#custom-footer)

```
$footer = '
    Page  of
';

PDF::view('report', $data)
    ->footer($footer)
    ->download();
```

### Available Placeholders in Headers/Footers

[](#available-placeholders-in-headersfooters)

- `` - Current page number
- `` - Total pages
- `` - Current date
- `` - Document title
- `` - Document URL

---

🔒 Security Features
-------------------

[](#-security-features)

### Password Protection

[](#password-protection)

```
// User password (required to open PDF)
PDF::view('confidential', $data)
    ->password('secret123')
    ->download();

// Owner password (required to modify)
PDF::view('document', $data)
    ->ownerPassword('admin123')
    ->download();
```

### Permissions

[](#permissions)

```
PDF::view('document', $data)
    ->allowPrinting(false)    // Disable printing
    ->allowCopy(false)        // Disable copying
    ->allowModify(false)      // Disable modifications
    ->download();
```

---

💧 Watermarks
------------

[](#-watermarks)

### Text Watermark

[](#text-watermark)

```
PDF::view('document', $data)
    ->watermark('CONFIDENTIAL')
    ->download();

// Custom watermark options
PDF::view('document', $data)
    ->watermark('DRAFT', [
        'opacity' => 0.5,
        'fontSize' => '60px',
        'color' => '#ff0000',
        'rotation' => -45,
    ])
    ->download();
```

---

📋 Metadata
----------

[](#-metadata)

### Document Properties

[](#document-properties)

```
PDF::view('report', $data)
    ->title('Annual Report 2025')
    ->author('John Doe')
    ->subject('Financial Report')
    ->keywords(['finance', 'annual', 'report'])
    ->creator('LaraPDFX')
    ->download();

// Or set all at once
PDF::view('document', $data)
    ->metadata([
        'title' => 'My Document',
        'author' => 'Jane Smith',
        'subject' => 'Important Report',
        'keywords' => 'business, report',
        'creator' => 'My Application',
    ])
    ->download();
```

---

🎨 CSS Support
-------------

[](#-css-support)

LaraPDFX supports **ALL modern CSS features** because it uses Chrome's rendering engine:

### ✅ Fully Supported

[](#-fully-supported)

- **CSS3** - All properties
- **Flexbox** - Complete support
- **Grid** - Full grid layouts
- **Custom fonts** - Web fonts, Google Fonts
- **RTL languages** - Arabic, Hebrew, Persian
- **Bootstrap** - All versions
- **Tailwind CSS** - Complete support
- **Animations** - CSS animations/transitions
- **Media queries** - Print media queries
- **Modern selectors** - :nth-child, :not, etc.
- **Background images** - All formats
- **SVG** - Inline and external
- **Box shadows** - All shadow effects
- **Border radius** - Rounded corners
- **Gradients** - Linear and radial
- **Transforms** - Rotate, scale, etc.

### Example with Modern CSS

[](#example-with-modern-css)

```
{{-- resources/views/pdf/modern-invoice.blade.php --}}

                Invoice

                Date: {{ $date }}

```

```
PDF::view('pdf.modern-invoice', $data)
    ->download('invoice.pdf');
```

---

🌍 RTL Language Support
----------------------

[](#-rtl-language-support)

Perfect support for Right-to-Left languages:

```
>

        body {
            font-family: 'Arial', sans-serif;
            direction: rtl;
            text-align: right;
        }

    مرحبا بك
    هذا نص تجريبي باللغة العربية

```

---

⚙️ Configuration
----------------

[](#️-configuration)

Edit `config/larapdfx.php`:

```
return [
    // Default paper format
    'paper' => [
        'format' => 'A4',
        'margins' => [
            'top' => 10,
            'right' => 10,
            'bottom' => 10,
            'left' => 10,
        ],
    ],

    // Chrome path (auto-detect if null)
    'chrome_path' => null,

    // Node.js paths
    'node_binary' => null,
    'npm_binary' => null,

    // Timeout in seconds
    'timeout' => 60,

    // Print background graphics
    'print_background' => true,

    // Default output directory
    'output_directory' => 'pdfs',

    // Queue settings
    'queue' => [
        'enabled' => false,
        'connection' => null,
        'queue' => 'default',
    ],
];
```

---

🔧 Advanced Usage
----------------

[](#-advanced-usage)

### Custom Chrome Path

[](#custom-chrome-path)

```
PDF::view('document', $data)
    ->setChromePath('/usr/bin/chromium-browser')
    ->download();
```

### Custom Timeout

[](#custom-timeout)

```
PDF::view('large-report', $data)
    ->timeout(120)  // 2 minutes
    ->download();
```

### Print Background

[](#print-background)

```
PDF::view('colorful-doc', $data)
    ->printBackground(true)  // Print background colors/images
    ->download();
```

### Prefer CSS Page Size

[](#prefer-css-page-size)

```
PDF::view('custom-layout', $data)
    ->preferCSSPageSize(true)  // Use CSS @page size
    ->download();
```

---

🎯 Real-World Examples
---------------------

[](#-real-world-examples)

### Invoice with Logo and Styling

[](#invoice-with-logo-and-styling)

```
{{-- resources/views/invoices/template.blade.php --}}

        body { font-family: Arial, sans-serif; }
        .header { background: #3490dc; color: white; padding: 20px; }
        .invoice-table { width: 100%; border-collapse: collapse; }
        .invoice-table th, .invoice-table td {
            border: 1px solid #ddd;
            padding: 8px;
        }

        INVOICE #{{ $invoice->number }}

                Item
                Quantity
                Price
                Total

            @foreach($invoice->items as $item)

                {{ $item->name }}
                {{ $item->qty }}
                ${{ $item->price }}
                ${{ $item->total }}

            @endforeach

```

```
// Controller
public function downloadInvoice($id)
{
    $invoice = Invoice::with('items')->findOrFail($id);

    return PDF::view('invoices.template', ['invoice' => $invoice])
        ->format('A4')
        ->margins(15)
        ->footerWithPageNumbers()
        ->title('Invoice #' . $invoice->number)
        ->author('Your Company')
        ->download('invoice-' . $invoice->number . '.pdf');
}
```

### Report with Charts (using Chart.js)

[](#report-with-charts-using-chartjs)

```

        const ctx = document.getElementById('myChart');
        new Chart(ctx, {
            type: 'bar',
            data: {
                labels: ['Jan', 'Feb', 'Mar'],
                datasets: [{
                    label: 'Sales',
                    data: [12, 19, 3],
                }]
            }
        });

```

---

🐛 Troubleshooting
-----------------

[](#-troubleshooting)

### Chrome Not Found

[](#chrome-not-found)

**Error:** `Chrome binary not found`

**Solution:**

```
# Ubuntu/Debian
sudo apt install chromium-browser

# Set path in config
'chrome_path' => '/usr/bin/chromium-browser',
```

### Timeout Issues

[](#timeout-issues)

**Error:** `Maximum execution time exceeded`

**Solution:**

```
PDF::view('large-doc', $data)
    ->timeout(180)  // Increase timeout
    ->download();
```

### Memory Issues

[](#memory-issues)

**Solution:**

```
// In php.ini
memory_limit = 512M

// Or in code
ini_set('memory_limit', '512M');
```

### Node.js Not Found

[](#nodejs-not-found)

**Solution:**

```
# Install Node.js
sudo apt install nodejs npm

# Or set path
'node_binary' => '/usr/bin/node',
```

---

📊 Performance Tips
------------------

[](#-performance-tips)

1. **Cache views** - Use Laravel's view caching
2. **Queue long PDFs** - Use Laravel queues for large documents
3. **Optimize images** - Compress images before including
4. **Minimize external resources** - Inline CSS/JS when possible
5. **Use local fonts** - Avoid loading fonts from CDN

---

🧪 Testing
---------

[](#-testing)

```
# Run tests
composer test

# Run with coverage
composer test-coverage
```

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

📝 License
---------

[](#-license)

LaraPDFX is open-sourced software licensed under the [MIT license](LICENSE).

---

👨‍💻 Author
----------

[](#‍-author)

**deecodek**
GitHub: [@deecodek](https://github.com/deecodek)

---

⭐ Show Your Support
-------------------

[](#-show-your-support)

If you find LaraPDFX helpful, please give it a star on GitHub!

---

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Built on top of [Spatie Browsershot](https://github.com/spatie/browsershot)
- Powered by Chrome/Chromium headless browser
- Inspired by the need for better PDF generation in Laravel

---

📚 Additional Resources
----------------------

[](#-additional-resources)

- [Documentation](https://github.com/deecodek/larapdfx)
- [Issue Tracker](https://github.com/deecodek/larapdfx/issues)
- [Changelog](CHANGELOG.md)

---

**Made with ❤️ for the Laravel community**

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96963649b6a38de5af132e1dab70333d63ffae4e24dc484795a1a6bf29fb342c?d=identicon)[deecodek](/maintainers/deecodek)

---

Top Contributors

[![PriyanshuKherade8](https://avatars.githubusercontent.com/u/94528908?v=4)](https://github.com/PriyanshuKherade8 "PriyanshuKherade8 (3 commits)")[![deecodek](https://avatars.githubusercontent.com/u/106729818?v=4)](https://github.com/deecodek "deecodek (1 commits)")

---

Tags

laravelpdfpuppeteerLaravel pdfchromiumbrowsershotCSS3html-to-pdfpdf-generationflexboxmodern-pdflarapdfx

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/deecodek-larapdfx/health.svg)

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[chrome-php/chrome

Instrument headless chrome/chromium instances from PHP

2.6k4.5M64](/packages/chrome-php-chrome)[spatie/laravel-pdf

Create PDFs in Laravel apps

9963.4M12](/packages/spatie-laravel-pdf)[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[tarfin-labs/easy-pdf

Makes pdf processing easy.

1718.3k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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