PHPackages                             vianetz/pdf-generator - 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. vianetz/pdf-generator

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

vianetz/pdf-generator
=====================

A library that supports method for generating PDF documents based on DomPdf and FPDI.

5.0.0(1y ago)130.2k↓33%GPL-3.0-or-laterPHPPHP ^7.4|^8CI passing

Since May 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/vianetz/pdf-generator)[ Packagist](https://packagist.org/packages/vianetz/pdf-generator)[ Docs](https://www.vianetz.com)[ RSS](/packages/vianetz-pdf-generator/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (22)Used By (0)

vianetz Pdf Library
===================

[](#vianetz-pdf-library)

This library offers an easy-to-use API for PDF generation and merging.
Internally it uses the [DomPDF library](https://github.com/dompdf/dompdf) for PDF generation and [FPDI](https://github.com/Setasign/FPDI) for merging.

More information about this PDF API can also be found [on my website](https://www.vianetz.com/en/pdf-invoice-api-magento/).

Usage
-----

[](#usage)

### Create PDF document from HTML contents

[](#create-pdf-document-from-html-contents)

```
// Create a new pdf instance.
$pdf = \Vianetz\Pdf\Model\PdfFactory::general()->create();

// Create the document. You can return any kind of HTML content here.
$document = new \Vianetz\Pdf\Model\HtmlDocument('Hello World!');

// Add our document to the pdf. You can add as many documents as you like
// as they will all be merged into one PDF file.
$pdf->add($document);

// Save the resulting PDF to file test.pdf - That's it :-)
$pdf->saveToFile('test.pdf');
```

### Merge a PDF file and a PDF string into one PDF file

[](#merge-a-pdf-file-and-a-pdf-string-into-one-pdf-file)

```
// Load some random PDF contents
$pdfString = file_get_contents('test1.pdf');

// Setup things
$pdfMerge = \Vianetz\Pdf\Model\PdfMerge::create();

// Do the merge.
$pdfMerge->mergePdfString($pdfString, 'background.pdf');
$pdfMerge->mergePdfFile('test2.pdf');

// Save the result PDF to file result.pdf.
file_put_contents($fileName, $pdfMerge->toPdf());
```

### Tips &amp; Tricks

[](#tips--tricks)

- The string literal `__PDF_TPC__` will be replaced with the total page count

Frequently Asked Questions
--------------------------

[](#frequently-asked-questions)

Please find the Frequently Asked Questions [on my website](https://www.vianetz.com/en/faq).

Support
-------

[](#support)

If you have any issues or suggestions with this extension, please do not hesitate to [contact me](https://www.vianetz.com/en/contacts).

License
-------

[](#license)

[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html)
See also LICENSE file.

This extension uses the DomPDF library. For license information please visit [the DomPdf repository](https://github.com/dompdf/dompdf).
This extension uses the FPDI library. For license information please visit [the FPDI repository](https://github.com/Setasign/FPDI/blob/master/LICENSE.txt).

This library uses Semantic Versioning - please find more information at [semver.org](http://semver.org).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance41

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

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

Recently: every ~217 days

Total

20

Last Release

493d ago

Major Versions

1.4.0 → 2.0.02020-11-05

2.2.0 → 3.0.02021-06-01

3.1.0 → 4.0.02023-07-09

4.0.2 → 5.0.02025-01-10

PHP version history (4 changes)1.2.2PHP ^5.6|^7

2.2.0PHP ^5.6|^7|^8

3.1.0PHP ^7|^8

4.0.0PHP ^7.4|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ff492874815eed37664a65070bcd600b4cbe9b0356afa8a9ae2482119fe98e4?d=identicon)[ma4nn](/maintainers/ma4nn)

---

Top Contributors

[![ma4nn](https://avatars.githubusercontent.com/u/26252058?v=4)](https://github.com/ma4nn "ma4nn (117 commits)")

---

Tags

pdfpdf-generationpdfvianetz

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vianetz-pdf-generator/health.svg)

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

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

PHP library generating PDF files from UTF-8 encoded HTML

4.7k77.1M493](/packages/mpdf-mpdf)[webklex/laravel-pdfmerger

Generic PDF merger for Laravel

1422.6M2](/packages/webklex-laravel-pdfmerger)[jurosh/pdf-merge

PHP PDF Merger

1522.2M5](/packages/jurosh-pdf-merge)[setasign/fpdi-protection

A FPDI compatible version of the FPDF\_Protection script.

324.3M2](/packages/setasign-fpdi-protection)

PHPackages © 2026

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