PHPackages                             alifahmmed/pdfbuilder - 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. alifahmmed/pdfbuilder

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

alifahmmed/pdfbuilder
=====================

Laravel 12 package: generate PDF via headless chromium or wkhtmltopdf without Node.js

1.0.0(9mo ago)03MITPHPPHP &gt;=8.1

Since Aug 11Pushed 9mo agoCompare

[ Source](https://github.com/s-m-alif-ahmmed/PdfBuilder)[ Packagist](https://packagist.org/packages/alifahmmed/pdfbuilder)[ Docs](https://github.com/s-m-alif-ahmmed/PdfBuilder)[ RSS](/packages/alifahmmed-pdfbuilder/feed)WikiDiscussions main Synced 1mo ago

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

PdfBuilder — Laravel PDF Generator without Node.js
==================================================

[](#pdfbuilder--laravel-pdf-generator-without-nodejs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c2dc88e7ab7a876ad9c5251db15f8d2453e4026821bc8520bbb368b9db51f65c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c696661686d6d65642f7064666275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alifahmmed/pdfbuilder)[![Total Downloads](https://camo.githubusercontent.com/ba18a206a787d2112dcedfc6fcbf9982cc241a5568c0aa8e4a475a9527276007/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c696661686d6d65642f7064666275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alifahmmed/pdfbuilder)[![License](https://camo.githubusercontent.com/c054b4cc2eb539b44b9e7c627b798bc720cbf973fca6baaf0fa95661c9ea9ae4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f732d6d2d616c69662d61686d6d65642f5064664275696c6465722e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/b70f4af001d177f97c77aeee03d0a5e17707b7c0b8f2a0066fb1f6bd05c1128a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616c696661686d6d65642f7064666275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alifahmmed/pdfbuilder)

**PdfBuilder** is a Laravel package for generating high-quality PDFs from HTML using `wkhtmltopdf` or headless Chromium — **without requiring Node.js**.
It supports **Bootstrap**, **Tailwind CSS**, and any modern HTML/CSS styling.

---

✨ Features
----------

[](#-features)

- Convert HTML to PDF directly in Laravel
- No Node.js required
- Supports **Bootstrap** and **TailwindCSS**
- Works with `wkhtmltopdf` binary (bundled or system-installed)
- Simple Facade API (`PdfBuilder::htmlToPdf()`)
- Configurable binary path, temp storage, and extra arguments
- Publish binary to your Laravel project for easy server deployment
- Works on **Laravel 9, 10, 11, and 12**

---

📦 Installation
--------------

[](#-installation)

Require the package via Composer:

```
composer require alifahmmed/pdfbuilder
```

⚙️ Configuration

1. Publish the config file and binary:

```
php artisan vendor:publish --provider="AlifAhmmed\PdfBuilder\PdfBuilderServiceProvider" --tag=config
php artisan vendor:publish --provider="AlifAhmmed\PdfBuilder\PdfBuilderServiceProvider" --tag=bin
```

2. Set up your .env variables:

```
PDFBUILDER_BINARY_PATH=/full/absolute/path/to/your/project/pdf-builder-bin/wkhtmltopdf
PDFBUILDER_RENDERER=wkhtmltopdf
```

3. Configuration file (config/pdfbuilder.php):

```
return [
    'default_renderer' => 'wkhtmltopdf',
    'binary_path' => env('PDFBUILDER_BINARY_PATH', 'wkhtmltopdf'),
    'temp_path' => env('PDFBUILDER_TEMP_PATH', storage_path('app/pdfbuilder')),
    'extra_args' => [
        '--enable-local-file-access',
        '--no-outline',
        '--quiet',
    ],
];
```

🚀 Basic Usage

Generate a PDF from HTML and return it as a download in a Laravel controller:

```
use PdfBuilder;

class PdfController extends Controller
{
    public function download()
    {
        $html = view('pdf.invoice', ['data' => $invoiceData])->render();
        $pdfContent = PdfBuilder::htmlToPdf($html);

        return response($pdfContent)
            ->header('Content-Type', 'application/pdf')
            ->header('Content-Disposition', 'attachment; filename="invoice.pdf"');
    }
}
```

🎯 Advanced Usage

1. Set Custom Page Options

```
$pdfContent = PdfBuilder::htmlToPdf($html, [
    'orientation' => 'landscape', // 'portrait' or 'landscape'
    'margin' => '10mm',
]);
```

2. Inline Local Images Automatically

```
use AlifAhmmed\PdfBuilder\Helpers;

$html = file_get_contents(resource_path('views/pdf/report.html'));
$htmlWithImages = Helpers::inlineImages($html, public_path('images'));

$pdfContent = PdfBuilder::htmlToPdf($htmlWithImages);
```

3. Store PDF to Disk

```
Storage::put('reports/monthly.pdf', PdfBuilder::htmlToPdf($html));
```

🛠 Requirements

- PHP &gt;= 8.1
- Laravel 9.x | 10.x | 11.x | 12.x
- wkhtmltopdf binary (system-installed or bundled via resources/bin)

🐛 Troubleshooting

- Binary not found Ensure wkhtmltopdf is installed or the .env path is correct.
- Permission denied Make sure the binary is executable:

```
  chmod +x pdf-builder-bin/wkhtmltopdf
```

- Fonts/CSS not applied Use absolute paths or the Helpers::inlineImages() method to embed assets.

📜 License

This package is open-sourced under the MIT license.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance57

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

280d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3af3c0ae537b65ab45f1b6cf345dc00327e959377c8a1be855884807b4db0e1e?d=identicon)[s-m-alif-ahmmed](/maintainers/s-m-alif-ahmmed)

---

Top Contributors

[![s-m-alif-ahmmed](https://avatars.githubusercontent.com/u/115633805?v=4)](https://github.com/s-m-alif-ahmmed "s-m-alif-ahmmed (2 commits)")

---

Tags

phplaravelpdfwkhtmltopdfjavascriptcsslaravel-packagePDF GENERATORbootstraptailwindcsshtml-to-pdfpdf-generationheadless-chromiumpdf-builder

### Embed Badge

![Health badge](/badges/alifahmmed-pdfbuilder/health.svg)

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

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

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

170125.8k](/packages/mostafaznv-pdf-optimizer)[wemersonjanuario/laravelpdf

Another HTML to PDF Converter for Laravel

2912.9k1](/packages/wemersonjanuario-laravelpdf)[lucasromanojf/laravel5-pdf

Provides the HTML2PDF functionality using the wkhtmltopdf library (Laravel 5)

1271.8k](/packages/lucasromanojf-laravel5-pdf)

PHPackages © 2026

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