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

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

famoser/pdf-generator
=====================

a clean pdf generator without dependencies

v0.7(1y ago)181.4k↑60%2[1 issues](https://github.com/famoser/pdf-generator/issues)MITPHPPHP &gt;=8.2CI passing

Since Jan 28Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/famoser/pdf-generator)[ Packagist](https://packagist.org/packages/famoser/pdf-generator)[ RSS](/packages/famoser-pdf-generator/feed)WikiDiscussions main Synced yesterday

READMEChangelog (8)Dependencies (6)Versions (12)Used By (0)

pdf-generator
=============

[](#pdf-generator)

[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE)[![PHP Composer](https://github.com/famoser/pdf-generator/actions/workflows/php.yml/badge.svg)](https://github.com/famoser/pdf-generator/actions/workflows/php.yml)

About
-----

[](#about)

Generates pdf files without any dependencies. Includes a layout engine to handle flow content (e.g. text spanning over more than one page).

```
composer require famoser/pdf-generator
```

This is still under active development ([contributions welcome!](./CONTRIBUTE.md)), and the public API is subject to change. If you are looking for a more mature project, see .

Getting started
---------------

[](#getting-started)

Using the printer:

```
// places "Hello world" in the top-left corner of the document.
$document = new Document();
$printer = $document->createPrinter();

$bodyText = new TextStyle(Font::createFromDefault());
$printer->printText('Hello world', $bodyText);

file_put_contents('example.pdf', $document->save());
```

The printer is useful when the exact position of elements is known. For example, for correspondence with fixed layout (e.g. the address in a letter) or for documents with page numbers. However, for many elements (such as tables) determining the exact position is cumbersome. For this, layouts are provided.

Using layouts:

```
// adds a rectangle, followed by "Hello moon".
// placement is decided by Flow, which places elements one-after-the-other.
$flow = new Flow();

$rectangle = new Rectangle(width: 120, height: 80, style: new DrawingStyle());
$flow->addContent($rectangle);

$text = new Text();
$text->addSpan('Hello moon', $bodyText);
$flow->add($text);

$document->add($flow);

file_put_contents('example.pdf', $document->save());
```

The layouts allow to declare *what* needs to be printed, and then takes care of the *where*. Provided are flows, grids, tables and text.

Examples
--------

[](#examples)

### Invoice

[](#invoice)

[Code](./examples/invoice.php) | [.pdf](./examples/invoice.pdf)

   [![Invoice](examples/invoice.png?raw=true)](examples/invoice.png?raw=true)  ### Book

[](#book)

[Code](./examples/book.php) | [.pdf](./examples/book.pdf)

   [![Book page 1](examples/book_1.png?raw=true)](examples/book_1.png?raw=true) [![Book page 2](examples/book_2.png?raw=true)](examples/book_2.png?raw=true)   [![Book page 3](examples/book_3.png?raw=true)](examples/book_3.png?raw=true) [![Book page 4](examples/book_4.png?raw=true)](examples/book_4.png?raw=true)

###  Health Score

46

↑

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% 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 ~309 days

Recently: every ~318 days

Total

8

Last Release

496d ago

PHP version history (3 changes)v0.1PHP ^7.1

v0.3PHP &gt;=7.4

v0.5PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/93517a280ea3701aec80a638183101a3a198e7e0d16ef9882f7b2742bfd7e4d3?d=identicon)[famoser](/maintainers/famoser)

---

Top Contributors

[![famoser](https://avatars.githubusercontent.com/u/5077020?v=4)](https://github.com/famoser "famoser (619 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

packagistpdf-generationphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

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