PHPackages                             anilsidhu/html2pdf-next - 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. anilsidhu/html2pdf-next

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

anilsidhu/html2pdf-next
=======================

A Simple package for easily generating PDF documents from HTML.This package is specially for laravel but you can use this without laravel.

078PHP

Since Dec 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/anil-sidhu/html2pdf-next)[ Packagist](https://packagist.org/packages/anilsidhu/html2pdf-next)[ RSS](/packages/anilsidhu-html2pdf-next/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel-Html2Pdf
================

[](#laravel-html2pdf)

[![Latest Stable Version](https://camo.githubusercontent.com/9bddf470d7b9431b8531f3c17b7ca9b9c92b0e746ca9ad4ea51b06025b05fb4a/68747470733a2f2f706f7365722e707567782e6f72672f6e61686964756c686173616e2f68746d6c327064662f762f737461626c65)](https://packagist.org/packages/nahidulhasan/html2pdf)[![Total Downloads](https://camo.githubusercontent.com/8d295dbb811a0ee6b61f32898074d6e8fe52668441857d91076f6dae9aed088a/68747470733a2f2f706f7365722e707567782e6f72672f6e61686964756c686173616e2f68746d6c327064662f646f776e6c6f616473)](https://packagist.org/packages/nahidulhasan/html2pdf)[![Latest Unstable Version](https://camo.githubusercontent.com/cf75a5854f40176683660d65330429c20b385cbe95ee7352ae95b88d55b944d1/68747470733a2f2f706f7365722e707567782e6f72672f6e61686964756c686173616e2f68746d6c327064662f762f756e737461626c65)](https://packagist.org/packages/nahidulhasan/html2pdf)[![License](https://camo.githubusercontent.com/52a92cf9bcc887a716d1b4e305cc6a3f8c53ccd573fb834aa0146c248a51b607/68747470733a2f2f706f7365722e707567782e6f72672f6e61686964756c686173616e2f68746d6c327064662f6c6963656e7365)](https://packagist.org/packages/nahidulhasan/html2pdf)

> A Simple package for easily generating PDF documents from HTML.This package is specially for laravel but you can use this without laravel.

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

[](#installation)

#### Install wkhtmltopdf

[](#install-wkhtmltopdf)

This was tested on:

- Ubuntu 14.04 x64
- Ubuntu 16.04 x64

```
sudo apt-get update
sudo apt-get install xvfb libfontconfig wkhtmltopdf
```

#### For docker

[](#for-docker)

```
RUN apt-get update && apt-get install xvfb libfontconfig wkhtmltopdf

```

#### Upddate Composer

[](#upddate-composer)

```
composer require nahidulhasan/html2pdf

```

If laravel version &lt; 5.5, add the ServiceProvider to the providers array in config/app.php

```
NahidulHasan\Html2pdf\Html2pdfServiceProvider::class,

```

You can optionally use the facade for shorter code. Add this to your facades:

```
'Pdf'  => NahidulHasan\Html2pdf\Facades\Pdf::class,

```

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

[](#basic-usage)

To create PDF add something like this to one of your controllers.

```
use NahidulHasan\Html2pdf\Facades\Pdf;

$document = Pdf::generatePdf('Test');
```

You can also create PDF from directly calling laravel blade file. Suppose you have a mail template named greeting in view/mails folder and want to send parameter then you have to call generatePdf method as described in below

```

$document =  Pdf::generatePdf(view('mails.greeting', ['name' => 'James', 'testVar' => 'demo']));
```

Now If you want to send mail to your client attaching pdf then you can follow this code

```
/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->from('username@gmail.com')
                ->view('mails.demo')
                ->attachData($document, 'Invoice.pdf');
}

```

### Other Usage

[](#other-usage)

It is also possible to use the following methods :

`pdf::download` Download the PDF file

`pdf::stream ` Open the PDF file in browser

### Running without Laravel

[](#running-without-laravel)

You can use this library without using Laravel.

Example:

```
use NahidulHasan\Html2pdf\Pdf;

$obj = new Pdf();
$document = $obj->generatePdf('Test');

```

### License

[](#license)

Html2PDF for Laravel is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2891110674249530028f8b75298252f3ca095b55b7a9addc5d90447b8addab15?d=identicon)[anil-sidhu](/maintainers/anil-sidhu)

---

Top Contributors

[![anil-sidhu](https://avatars.githubusercontent.com/u/14924211?v=4)](https://github.com/anil-sidhu "anil-sidhu (4 commits)")

### Embed Badge

![Health badge](/badges/anilsidhu-html2pdf-next/health.svg)

```
[![Health](https://phpackages.com/badges/anilsidhu-html2pdf-next/health.svg)](https://phpackages.com/packages/anilsidhu-html2pdf-next)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

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

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

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