How I Built a Fluent PDF Library and Visual Drag-and-Drop Builder for PHP

php dev.to

After years of struggling with PDF generation in PHP, I finally decided to do something about it.

I was tired of losing time manually adjusting coordinates, dealing with heavy and inflexible libraries, and writing code that was difficult to maintain and modify later.

So I built arabel-pdf — a modern, lightweight PDF library — and its companion Arabel PDF Builder, a visual drag-and-drop tool that generates real PHP code.


The Problem

Generating clean, professional, and maintainable PDFs in PHP is still surprisingly painful in 2026.

Most solutions force you into one of two worlds:

  • HTML/CSS-based rendering — which becomes messy with complex layouts
  • Manual coordinate positioning — which is precise but extremely time-consuming to update

I wanted a better middle ground.


What I Built

1. arabel-pdf

A lightweight (~100 KB), zero-dependency PDF library for PHP 8.1+ with a clean fluent API.

Features:

  • Grid-based layout with row() and col()
  • Tables with colspan and rowspan
  • Repeating headers and footers
  • Panels, images, colors, and more
composer require arabel/pdf:^0.6.0
Enter fullscreen mode Exit fullscreen mode

2. Arabel PDF Builder (currently in alpha)

A fully browser-based visual builder where you can:

  • Drag and drop elements (text, images, tables, panels…)
  • Build responsive layouts with live preview
  • Generate clean, real PHP code for arabel-pdf (and optionally for mPDF or FPDF)

Everything runs client-side — no data is sent to any server.


A Quick Comparison

Feature arabel/pdf mPDF DomPDF FPDF / TCPDF
Dependencies 0 Many Many 0 (FPDF) / Some
Package size ~100 KB >10 MB Large Small / Medium
API Style Fluent (row/col) HTML/CSS HTML/CSS Coordinate-based
Grid / Modern Layout Yes No Limited No

The Builder in Action

The most enjoyable part is using the visual builder at arabel.dev.

You design your layout visually, see the result in real time, and then copy the generated PHP code directly into your project. It saves a huge amount of time, especially when clients ask for small changes.


Real Example: Invoice Template

One of the most complete examples available is the Invoice. Here's a simplified version of the code generated by the builder:

use Arabel\Pdf\Document;

$doc = Document::create()
    ->header(/* ... */)
    ->row()
        ->col(8)->text('Invoice #2026/001', 'h1')
        ->col(4)->text('Date: 17/04/2026')
    ->endRow()
    // ... product table, totals, taxes, footer
    ->save('invoice.pdf');
Enter fullscreen mode Exit fullscreen mode

Current Status & What's Next

  • arabel-pdf: v0.6.0 — stable for most use cases
  • PDF Builder: Alpha — free during alpha. The builder still has known bugs; if you run into something, open an issue on GitHub — your feedback directly shapes what I fix next."

On the roadmap:

  • Import existing PDFs and convert them into editable code (for arabel-pdf, mPDF and FPDF)
  • More ready-made templates (invoices, reports, contracts, etc.)
  • Save and load templates + custom widgets
  • Official Laravel integration (Facade + Service Provider)

I'm actively working on these features and prioritizing based on community feedback.


Try It and Help Me Improve

If you work with PDFs in PHP and you're tired of the usual struggles, I'd love for you to try the tools:

Try the Visual PDF Builder → arabel.dev

GitHub – arabel-pdf (MIT License)

Leave a comment here or open an issue on GitHub:

  • What feature is missing for you?
  • Which template would you like to see ready-made?
  • Any feedback on the API or the builder?

Every ⭐ star, comment, or share helps a lot at this early stage. Thank you for reading!

Source: dev.to

arrow_back Back to Tutorials