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

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

arabel/pdf
==========

Lightweight, zero-dependency and fast PDF generator for PHP 8.1+. Fluent &amp; semantic API with high-level Document and low-level Pdf layers.

v0.6.0(3mo ago)06MITPHPPHP &gt;=8.1

Since Apr 10Pushed 2mo agoCompare

[ Source](https://github.com/memphis90/arabel-pdf)[ Packagist](https://packagist.org/packages/arabel/pdf)[ RSS](/packages/arabel-pdf/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)DependenciesVersions (7)Used By (0)

arabel/pdf
==========

[](#arabelpdf)

**Lightweight · Zero-Dependency · Fast** — PDF generation for PHP 8.1+

[![PHP Version](https://camo.githubusercontent.com/c0761d101b201f2531c8037e6264420e2e43705d3776a9fcfb70c8cf3d3563a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242342e737667)](https://camo.githubusercontent.com/c0761d101b201f2531c8037e6264420e2e43705d3776a9fcfb70c8cf3d3563a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242342e737667)[![Downloads](https://camo.githubusercontent.com/05b0fd120ea75e8607817e80fba99b8fa60f2cf2668f7ba6b502fc95072c0180/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61726162656c2f706466)](https://camo.githubusercontent.com/05b0fd120ea75e8607817e80fba99b8fa60f2cf2668f7ba6b502fc95072c0180/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61726162656c2f706466)[![License](https://camo.githubusercontent.com/64aeacdc189b08b5310841e8cfe2e607d404919dbf8de6d9dfbefaf069ce9851/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61726162656c2f706466)](https://camo.githubusercontent.com/64aeacdc189b08b5310841e8cfe2e607d404919dbf8de6d9dfbefaf069ce9851/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61726162656c2f706466)

Generate PDFs with a **fluent, semantic API** — no mPDF, no dompdf, no TCPDF bloat.
Two layers: a high-level **Document API** for reports and invoices, and a low-level **Pdf API** for pixel-perfect control.

> **Work in progress.** The API is functional and tested, but breaking changes may occur before v1.0.

---

Why arabel/pdf?
---------------

[](#why-arabelpdf)

Most PHP PDF libraries are either **too heavy** (mPDF, TCPDF ship megabytes of dependencies) or **too low-level** (raw PDF forces you to think in millimetres for everything).

`arabel/pdf` gives you the best of both worlds:

arabel/pdfmPDFdompdfTCPDFDependencies0ManyManySomeSpeed⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐Fluent API✅Partial✗✗PHP 8.1+ native✅PartialPartial✗Package size**~100 KB**&gt; 10 MBLargeLarge*Based on community benchmarks and package sizes. Formal benchmarks coming in v1.0.*

---

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

[](#installation)

```
composer require arabel/pdf
```

**Requirements:** PHP 8.1+ · Extensions `zlib` and `iconv` (both enabled by default in most environments) · `GD` for PNG images with alpha channel

---

Two layers
----------

[](#two-layers)

```
┌──────────────────────────────────────────┐
│  Document  — high-level, recommended     │
│  row / col / h1 / h2 / p / table...      │
└──────────────────┬───────────────────────┘
                   │ delegates to
┌──────────────────▼───────────────────────┐
│  Pdf  — low-level, mm-precise            │
│  cell / text / rect / line / image...    │
└──────────────────────────────────────────┘

```

Start with **Document** — no millimetres, no cursor math.
Drop down to **Pdf** via `$doc->raw()` when you need exact positioning.

---

Document API
------------

[](#document-api)

### Basic example

[](#basic-example)

```
use Arabel\Pdf\Document;
use Arabel\Pdf\DocumentStyle;

$style = new DocumentStyle();
$style->h1(22, [15, 55, 120], 'B', 12)
      ->h2(12, [15, 55, 120], 'B', 8)
      ->p(9,  [60, 60, 60],   '',  5.5);

$doc = new Document('Helvetica', $style);

$doc->addPage()
    ->h1('Monthly Report')
    ->h2('Sales — April 2026')
    ->hr()
    ->spacer()
    ->p('Summary of current month sales compared to the previous period.')
    ->output('report.pdf', 'F');
```

### Named headers and footers

[](#named-headers-and-footers)

Define repeatable headers and footers once — they are applied automatically on every `addPage()`.
Multiple named variants let you use different headers for different sections.

```
// Default header — applied to every addPage()
$doc->setHeader()
    ->bg([15, 55, 120])
    ->fg([255, 255, 255])
    ->left('ARABEL SRL', 'Software & Digital Products')
    ->right('FATTURA', '# INV-2026-0042')
    ->height(22);

// Named header — applied explicitly
$doc->setHeader('allegato')
    ->bg([15, 55, 120])
    ->fg([255, 255, 255])
    ->left('ALLEGATO A — Dettaglio attività', 'Fattura INV-2026-0042');

// Footer with page number
$doc->setFooter()
    ->left('Arabel Srl — P.IVA IT09876543210')
    ->right('Pagina {page}');

$doc->addPage();                // → 'default' header + footer
$doc->addPage('P', 'allegato'); // → 'allegato' header + footer
$doc->addPage('P', false);      // → no header, footer only
```

### Automatic page break

[](#automatic-page-break)

Content never overlaps the footer. Before rendering each element, the Document measures its height and triggers a new page automatically if it would exceed the safe area.

### Grid layout — row / col

[](#grid-layout--row--col)

The page is divided into a **12-column grid**. Use `col($span)` to define how many columns a block occupies (1–12).

```
$doc->addPage()
    ->h1('Dashboard')
    ->spacer()

    ->row()
        ->col(8)->p('Left side — takes 8 of 12 columns.')
        ->col(4)->h2('€ 24,500')
    ->endRow()

    ->row()
        ->col(4)->h2('142 PDFs')
        ->col(4)->h2('38 upgrades')
        ->col(4)->h2('94% satisfaction')
    ->endRow()
    ->row()
        ->col(4)->p('generated this month')
        ->col(4)->p('Free → Pro conversions')
        ->col(4)->p('satisfaction index')
    ->endRow()

    ->output('dashboard.pdf', 'F');
```

### Images in columns

[](#images-in-columns)

Use `col()->image()` to embed a JPEG or PNG directly inside the grid.
Height is auto-calculated from the image's aspect ratio — pass an explicit `$h` (mm) to override.
PNG files with alpha channel are supported: the alpha layer is composited against white.

```
$doc->row()
    ->col(3)->image('logo.png')        // auto height from aspect ratio
    ->col(3)->image('badge.png', 20)   // forced 20 mm height
    ->col(6)->h1('Company Name')
->endRow();
```

### Tables

[](#tables)

```
$doc->addPage()
    ->h1('Product List')
    ->spacer()

    ->table(['Product', 'Category', 'Qty', 'Revenue'])
        ->widths([3, 2, 1, 1])
        ->align(['L', 'L', 'C', 'R'])
        ->tr(['Arabel PDF',     'Library', '142', '€ 0'])
        ->tr(['Arabel Builder', 'Tool',      '38', '€ 1,862'])
        ->tr(['Arabel Suite',   'Bundle',    '12', '€ 2,388'])
    ->endTable()

    ->output('products.pdf', 'F');
```

`widths()`, `align()`, and `tr()` can be called in **any order** — rendering is deferred to `endTable()`.

**Colspan** — merge cells across columns:

```
->table(['Descrizione', 'Qty', 'Prezzo', 'IVA', 'Totale'])
    ->tr(['Arabel PDF', '1', '€ 49,00', '22%', '€ 59,78'])
    ->tr([
        ['text' => 'Subtotale:', 'colspan' => 4, 'align' => 'R'],
        ['text' => '€ 59,78',                    'align' => 'R'],
    ])
->endTable()
```

### Colored panels

[](#colored-panels)

```
$doc->panel()
        ->bg([15, 55, 120])
        ->fg([255, 255, 255])
        ->padding(5)
        ->h2('TOTALE FATTURA:')
        ->b('€ 13.344,36')
    ->endPanel();
```

Background is measured and drawn before text — no coordinate math required.

### DocumentStyle

[](#documentstyle)

```
$style = new DocumentStyle();

// Fluent configurators (recommended)
$style->h1(22, [15, 55, 120], 'B', 12)
      ->h2(12, [15, 55, 120], 'B', 8)
      ->p(9,  [60, 60, 60],   '',  5.5);

// Table style
$style->tableHeadBg = [15, 55, 120];
$style->tableHeadFg = [255, 255, 255];
$style->tableAltBg  = [235, 241, 255];
$style->tableRowH   = 7.0;
$style->tableLineH  = 5.0;
```

### Document methods reference

[](#document-methods-reference)

MethodDescription`setMargins(l, t, r, b)`Override default 15 mm margins — call before `addPage()``addPage('P'|'L', $header)`New page — portrait or landscape, optional named header`setHeader(string $name = 'default')`Register a named header → `Header``setFooter(string $name = 'default')`Register a named footer → `Footer``h1(string)`Large heading`h2(string)`Section heading`p(string)`Body paragraph`b(string)`Bold paragraph`i(string)`Italic paragraph`bi(string)`Bold + italic paragraph`hr()`Horizontal rule`spacer(float $mm = 6)`Vertical blank space`row()`Open a 12-column grid row → `Row``col(int)->image(file, h)`Embed image in a column — auto height from aspect ratio`table(array $headers)`Open a table → `Table``panel()`Open a colored content block → `Panel``output(string, string)`Finalize and output the PDF`raw()`Access the underlying `Pdf` instance`getCursorY()`Current Y position in mm`colX(int $startSpan)`X coordinate of a grid column — use with `raw()``colW(int $span)`Width of N grid columns — use with `raw()`---

Pdf API
-------

[](#pdf-api)

Use `Pdf` directly when you need pixel-precise control.

```
use Arabel\Pdf\Pdf;

$pdf = new Pdf();

$pdf->addPage()
    ->setFont('Helvetica', 14)
    ->setTextColor(41, 98, 255)
    ->text(20, 30, 'Hello from Pdf')
    ->setFillColor(240, 240, 240)
    ->cell(100, 10, 'Cell with border', 1, 1, 'C')
    ->setDrawColor(180, 0, 0)
    ->line(10, 60, 200, 60)
    ->image('logo.png', 10, 70, 40)
    ->output('output.pdf', 'F');
```

All mutating methods return `static` — the full API is fluent.

### Pdf methods reference

[](#pdf-methods-reference)

MethodDescription`addPage('P'|'L')`New page`setFont(family, size, style)`Set font family, size in pt, style ('B', 'I', 'BI')`setTextColor(r, g, b)`Text colour (0–255 per channel)`setFillColor(r, g, b)`Fill colour for cells and rects`setDrawColor(r, g, b)`Stroke colour for borders and lines`setLineWidth(float)`Line thickness in mm`setMargins(l, t, r, b)`Page margins in mm`setXY(x, y)`Move cursor to absolute position (mm)`getX() / getY()`Current cursor position in mm`getStringWidth(string)`Measure string width in mm`text(x, y, string)`Print text at absolute position`cell(w, h, text, border, ln, align)`Render a cell, advance cursor`rect(x, y, w, h, style)`Draw a rectangle`line(x1, y1, x2, y2)`Draw a line`image(file, x, y, w, h)`Embed a JPEG or PNG image`output(name, dest)`Finalize and output the PDF### `output()` destinations

[](#output-destinations)

DestBehaviour`'D'`Force browser download (default)`'I'`Open inline in browser`'F'`Save to file (`$name` = full path)`'S'`Return raw PDF bytes as string---

Mixing both layers
------------------

[](#mixing-both-layers)

```
$doc = new Document();

$doc->addPage()
    ->h1('Invoice #1042');

// Drop to Pdf for a precise watermark
$doc->raw()
    ->setFont('Helvetica', 60)
    ->setTextColor(230, 230, 230)
    ->text(25, 120, 'DRAFT');

// Back to Document
$doc->spacer()
    ->table(['Description', 'Amount'])
        ->tr(['Consulting', '€ 800'])
    ->endTable()
    ->output('invoice.pdf', 'F');
```

---

Roadmap to v1.0
---------------

[](#roadmap-to-v10)

- Fluent Document API (row/col grid, tables, headings)
- Bold / italic font support with dynamic font registry
- Document style customization (`DocumentStyle`)
- Text wrapping in `col()`, tables, and Document methods
- Table column alignment and colspan
- Colored panels (`panel()`)
- Named repeatable headers and footers
- Automatic page break before footer safe area
- Fluent `DocumentStyle` configurators (`h1/h2/p()`)
- Table helper for totals rows
- `money()` / `date()` formatting helpers
- PNG with alpha channel / logo support (`col()->image()`, auto aspect ratio)
- Expanded test coverage and official benchmarks

---

License
-------

[](#license)

MIT © [Arabel](https://arabel.dev)

---

⭐ If you find this useful, a star goes a long way.
Issues, feedback, and PRs are very welcome.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance83

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

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.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

103d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/126269622?v=4)[Alessio](/maintainers/memphis90)[@memphis90](https://github.com/memphis90)

---

Top Contributors

[![memphis90](https://avatars.githubusercontent.com/u/126269622?v=4)](https://github.com/memphis90 "memphis90 (18 commits)")

---

Tags

pdffluentreportPDF GENERATORlightweightdocumentphp8no-dependenciesphp81zero-dependencyfast-pdf

### Embed Badge

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

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

###  Alternatives

[tecnickcom/tc-lib-pdf

PHP PDF Library

1.9k539.9k16](/packages/tecnickcom-tc-lib-pdf)[jimmyjs/laravel-report-generator

Rapidly Generate Simple Pdf &amp; Excel Report on Laravel 5 (Using Barryvdh/DomPdf or Barryvdh/laravel-snappy &amp; maatwebsite/excel)

577165.5k1](/packages/jimmyjs-laravel-report-generator)[omaralalwi/gpdf

Custom PDF wrapper supporting Arabic language

15521.6k](/packages/omaralalwi-gpdf)[quilhasoft/jasperphp

Pure PHP library to read JRXML files made with 'JasperSoft Studio' and generate reports in PDF

7744.6k1](/packages/quilhasoft-jasperphp)[rockett/weasyprint

A feature-rich WeasyPrint wrapper for generating PDFs from HTML and CSS, with support for PDF/A, PDF/UA, attachments, and optional Laravel integration.

30224.7k](/packages/rockett-weasyprint)[tecnickcom/tc-lib-pdf-parser

PHP library to parse PDF documents

38126.9k9](/packages/tecnickcom-tc-lib-pdf-parser)

PHPackages © 2026

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