PHPackages                             snono/pdf-builder - 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. snono/pdf-builder

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

snono/pdf-builder
=================

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

4138PHPCI failing

Since May 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/yasergh/PDFBuilder)[ Packagist](https://packagist.org/packages/snono/pdf-builder)[ RSS](/packages/snono-pdf-builder/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Report Builder
==============

[](#report-builder)

Generate PDF report like (invoice, receipt ) for laravel

Requirement
-----------

[](#requirement)

- php &gt;= 5.4.0
- Mpdf/Mpdf
- illuminate/support
- illuminate/view

---

Install with composer
---------------------

[](#install-with-composer)

```
composer require snono/pdf-builder
```

Publish the Configration
------------------------

[](#publish-the-configration)

```
php artisan vendor:publish
```

Example Usage: First you need add import class ReportBuilder

```
use Snono\PDFBuilder\Builder\Classes\PDFBuilder;
```

see example sample code blow

```
$invoice = PDFBuilder::make()
            ->setTemplate('default')
            ->setData($data)
            ->show();
```

### Configuration

[](#configuration)

to change default configuration of PDFBuilder update file `pdf.conf` in config directory of laravel project

### Methods

[](#methods)

#### Setting Template

[](#setting-template)

Use **setTemplate**() to set HTML template blade for laravel the default path in resources/view/pdf-builder

##### Example

[](#example)

```
$pdf =  PDFBuilder::make()
    ->setTemplate('pdf')
    ->setData($data)
    ->show()
```

#### Setting CSS for template

[](#setting-css-for-template)

Use **setCssUrls**() to set array of url string to css stylesheet files

##### Example

[](#example-1)

```
$pdf =  PDFBuilder::make()
    ->setCssUrls(array('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'))
    ->setTemplate('pdf')
    ->setData($data)
    ->show()
```

#### Setting Directionality

[](#setting-directionality)

Use **setDirectionality**() to ser direction of language take string option ('ltr' OR 'rtl')

##### Example

[](#example-2)

```
$pdf =  PDFBuilder::make()
    ->setCssUrls(array('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'))
    ->setTemplate('pdf')
    ->setData($data)
    ->setDirectionality('rtl')
    ->show();
```

#### Setting Header/Footer For the whole document

[](#setting-headerfooter-for-the-whole-document)

Use **setFooter**() and/or **SetHeader**() to set header/footer before writing the document ,The text sting defines three stings divided by `|` which will set a header at the left/centre/right margin of the page

##### Example

[](#example-3)

```
$pdf =  PDFBuilder::make()
    ->setCssUrls(array('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'))
    ->setTemplate('pdf')
    ->setHeader('Document Title')
    ->setFooter('Document Title|{PAGENO}|{DATE j-m-Y}')
    ->setData($data)
    ->setDirectionality('rtl')
    ->show();
```

#### Set Header/Footer from HTML string for the whole document

[](#set-headerfooter-from-html-string-for-the-whole-document)

Use setHTMLHeader() and/or setHTMLFooter() to set HTML headers/footers before writing to the document.

##### Description

[](#description)

void **setHTMLHeader** ( string $html \[, string $side \[, boolean $write \]\])

void **setHTMLFooter** ( string $html \[, string $side \[, boolean $write \]\])

##### Parameters

[](#parameters)

$header This parameter specifies the content of the page header as a string of valid HTML code.

Default: BLANK

$side Specify whether to set the header for ODD or EVEN pages in a DOUBLE-SIDED document.

Values (case-sensitive)

'O' - set the header for ODD pages

'E' - set the header for EVEN pages

Default: BLANK, which sets 'O'

$write If true it forces the Header to be written immediately to the current page. Use if the header is being set after the new page has been added.

Default: false

#### Generate Pdf file

[](#generate-pdf-file)

Finalise the document and send it to specified destination , you can use one method below

```
 $pdf->download($filename)
```

send to the browser and force a file download with the name given by $filename

```
$pdf->show($filename)
```

send the file inline to the browser.

```
$pdf->save( $filename)
```

save to a local file with the name given by $filename (may include a path).

```
$result = $pdf->toString()
```

return the document as a string.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60.9% 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://avatars.githubusercontent.com/u/3448788?v=4)[Yaser](/maintainers/yasergh)[@yasergh](https://github.com/yasergh)

---

Top Contributors

[![snonosystems-old](https://avatars.githubusercontent.com/u/31889306?v=4)](https://github.com/snonosystems-old "snonosystems-old (14 commits)")[![yasergh](https://avatars.githubusercontent.com/u/3448788?v=4)](https://github.com/yasergh "yasergh (9 commits)")

### Embed Badge

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

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

###  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)
