PHPackages                             belalkhandev/larapdf - 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. belalkhandev/larapdf

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

belalkhandev/larapdf
====================

Advanced Laravel PDF generation package with full Tailwind CSS and custom font support

v0.1.2(2mo ago)217↓50%MITPHPPHP ^8.1

Since Mar 3Pushed 2mo agoCompare

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

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

LaraPdf
=======

[](#larapdf)

Advanced Laravel PDF generation package built for the modern web. Pixel-perfect, Tailwind CSS ready, and complex script support (like Bengali) out of the box.

---

Why LaraPdf?
------------

[](#why-larapdf)

Generating PDFs in Laravel has historically been a pain. Traditional libraries often struggle with:

- **Modern CSS**: Flexbox, Grid, and Tailwind CSS utility classes rarely work correctly.
- **Complex Scripts**: Bengali, Arabic, or Hindi fonts often render as gibberish or broken boxes.
- **Environment Discrepancies**: "It works on my machine but not on the server" due to missing system dependencies.

**LaraPdf** solves these by using a real Headless Chrome engine (via Puppeteer). What you see in your browser is exactly what you get in your PDF.

### The Experience

[](#the-experience)

- ✨ **Developer Friendly**: A clean, fluent API that feels like native Laravel.
- 🎨 **Visual Excellence**: Full support for Tailwind CSS, background colors, and gradients.
- 🔡 **Font Mastery**: Seamless integration for Google Fonts and complex Unicode scripts.
- ⏳ **Smart Rendering**: Automatically waits for network idle to ensure all assets are loaded.
- 🚀 **Zero-Config**: Built-in command to install and manage Chrome within your project.

---

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

[](#installation)

You can install the package via composer:

```
composer require belalkhandev/larapdf
```

Publish the config file:

```
php artisan vendor:publish --tag=belalkhandev-larapdf-config
```

Install Puppeteer (required):

```
npm install puppeteer --save
```

Basic Usage
-----------

[](#basic-usage)

```
use Belal\LaraPdf\Facades\PDF;

PDF::loadView('invoices.template', ['invoice' => $invoice])
    ->download('invoice.pdf');
```

Advanced Usage
--------------

[](#advanced-usage)

```
PDF::loadView('reports.annual', $data)
    ->paperSize('A4')
    ->orientation('landscape')
    ->margins(15, 15, 15, 15)
    ->withTailwind()
    ->font('Inter', resource_path('fonts/Inter.ttf'))
    ->googleFont('Inter')
    ->headerView('pdf.header', ['company' => $company])
    ->footerView('pdf.footer')
    ->waitUntilNetworkIdle()
    ->timeout(120)
    ->saveToDisk('reports/annual-2026.pdf', 's3');
```

### HTML Preview

[](#html-preview)

For faster development, you can preview the rendered HTML directly in your browser without generating a PDF.

```
PDF::loadView('invoice', $data)
    ->withTailwind()
    ->preview(); // Returns an Illuminate\Http\Response
```

Or just get the raw HTML string:

```
$html = PDF::loadView('invoice', $data)->toHtml();
```

### Custom Fonts

[](#custom-fonts)

LaraPdf supports both local font files and Google Fonts seamlessly:

```
PDF::loadView('invoice', $data)
    ->googleFont('Inter') // Load 'Inter' from Google Fonts
    ->font('BrandFont', resource_path('fonts/brand.ttf')) // Load a local .ttf file
    ->stream();
```

Note

When using `googleFont()`, the package fetches and inlines the font CSS for reliability in isolated Puppeteer contexts.

### Paper Size &amp; Orientation

[](#paper-size--orientation)

```
// Standard size
PDF::loadView('invoice', $data)
    ->paperSize('a4') // a3, a4, a5, letter, etc.
    ->orientation('landscape')
    ->stream();

// Custom size (width, height, unit)
// Supports: mm, cm, in, px
PDF::loadView('invoice', $data)
    ->paperSize(100, 200, 'mm')
    ->stream();
```

### Margins

[](#margins)

Set margins in millimeters (top, right, bottom, left):

```
PDF::loadView('invoice', $data)
    ->margins(10, 10, 10, 10)
    ->stream();
```

Header and Footer Support
-------------------------

[](#header-and-footer-support)

LaraPdf makes it incredibly easy to add headers and footers to your PDFs.

### 1. Automatic Extraction (easiest)

[](#1-automatic-extraction-easiest)

Just use `` and `` tags directly in your Blade view. LaraPdf will extract them and repeat them on every page automatically.

```

    Page

```

### 2. Manual Definition

[](#2-manual-definition)

You can also define headers and footers using the fluent API:

```
PDF::loadView('reports.annual', $data)
    ->headerView('pdf.header', ['title' => 'Annual Report'])
    ->footerView('pdf.footer')
    ->stream();
```

Tip

LaraPdf automatically adjusts your top and bottom margins to **35mm** when a header or footer is detected. It also includes built-in support for common Tailwind utility classes (`flex`, `justify-between`, `font-bold`, `text-green-600`, etc.) inside headers and footers for easy styling.

Queue Support
-------------

[](#queue-support)

```
PDF::loadView('reports.heavy', $data)
    ->queue('reports/heavy.pdf', 's3');
```

Troubleshooting
---------------

[](#troubleshooting)

### "Could not find Chrome" error

[](#could-not-find-chrome-error)

This usually happens when Puppeteer cannot find the browser executable in its default cache directory.

#### 1. Automatic Install (Smart Detection)

[](#1-automatic-install-smart-detection)

Run the built-in command. It will automatically detect if you have a system Chrome installed and suggest using it to save 600MB:

```
php artisan larapdf:install-chrome
```

If not found, it will download a project-specific version. It is smart enough to skip the download if already installed.

#### 2. Specify Cache Path (Recommended for pnpm/Shared Hosting)

[](#2-specify-cache-path-recommended-for-pnpmshared-hosting)

If you are using pnpm or a restricted environment, specify a custom cache path in your `.env`:

```
PDF_PUPPETEER_CACHE_PATH=/var/www/your-project/storage/puppeteer
```

Then run the install command again.

#### 3. Use System Chrome

[](#3-use-system-chrome)

If you already have Chrome/Chromium installed on your system:

```
PDF_CHROME_PATH=/usr/bin/google-chrome
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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 ~0 days

Total

12

Last Release

76d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/924917772f8c6f5fcd56634f48ada82c1a1d192725190e5a3bc3e0894194687b?d=identicon)[belalkhandev](/maintainers/belalkhandev)

---

Top Contributors

[![belalkhandev](https://avatars.githubusercontent.com/u/41659455?v=4)](https://github.com/belalkhandev "belalkhandev (20 commits)")

### Embed Badge

![Health badge](/badges/belalkhandev-larapdf/health.svg)

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[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)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[elibyy/tcpdf-laravel

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

3542.7M5](/packages/elibyy-tcpdf-laravel)[stevebauman/autodoc-facades

Auto-generate PHP doc annotations for Laravel facades

98186.6k9](/packages/stevebauman-autodoc-facades)

PHPackages © 2026

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