PHPackages                             drewlabs/php-dompdf - 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. drewlabs/php-dompdf

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

drewlabs/php-dompdf
===================

Simple wrapper around php dompdf/dompdf library

v0.9.0(3y ago)0258MITPHPPHP &gt;=7.1

Since Nov 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/azandrew-sidoine/php-dom-pdf)[ Packagist](https://packagist.org/packages/drewlabs/php-dompdf)[ RSS](/packages/drewlabs-php-dompdf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Library Documentation
=====================

[](#library-documentation)

This library is build on top of \[\] PHP library for converting html document to PDF. It provides users with API for reading document from file path, psr7 stream object or even PHP SplFileInfo class. It also provides developpers with a response object that inherit from symfony HTTP response object for returns PDF as response.

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

[](#installation)

The library is build with composer requirements in mind and requires `composer` package manager for installation. To install the library to your PHP project:

> composer require drewlabs/php-dompdf

Usage
-----

[](#usage)

To create a PDF instance, use the proxy function provides by the package:

```
use function  Drewlabs\Dompdf\Proxy\DomPdf;

const pdf = DomPdf([/* DOMPdf otpions */]);
```

The package provides a factory class for creating DOMPdf instances. For Object Oriented enthousiast, creating a dom-pdf instance is simply as:

```
use Drewlabs\Dompdf\Factory;

$factory = new Factory;

const pdf = $factory->create([/* DOMPdf otpions */]);
```

- Reading DOM string

The `Dompdf` provides developper with various method for loading DOM string from system path, `SplFileInfo` instance, psr7 compatible stream object or inline string.

\-- Generic method

For all mentionned above types, the library provide a single method for reading dom string:

```
use function  Drewlabs\Dompdf\Proxy\DomPdf;
use Nyholm\Psr7\Factory\Psr17Factory;

const pdf = DomPdf([/* DOMPdf otpions */]);

// Reading DOM string from \SplFileInfo
$document = new \SplFileInfo;
$pdf = $pdf->read($document);

// Reading from Psr7 compatible stream
$document = (new Psr17Factory)->createStreamFromFile($pathOrStream);
$pdf = $pdf->read($document);

// Reading from disk path
$pdf = $pdf->read('/home/users/dev/documents/document.pdf');

// Read from raw string
$pdf = $pdf->read("

        Document

    "
);

// Read from URI resource
$pdf = $pdf->read("https://www.google.com");
```

Aside the generic method `Domdfp::read`, the library provides a 2 additional method for reading raw string or url resource.

```
use function  Drewlabs\Dompdf\Proxy\DomPdf;

$pdf = DomPdf([/* DOMPdf otpions */]);
$pdf->html(" ... html string");

// To load content from URI resource
$pdf = $pdf->resource('file:///home/users/dev/documents/document.pdf');
```

### Utility methods

[](#utility-methods)

- Set pdf orientation

`setPaperOrientation($size, $orientation)` is the API provided to modify the paper size and orientation.

> size : Drewlabs\\Dompdf\\Size::LETTER, Drewlabs\\Dompdf\\Size::LEGAL, Drewlabs\\Dompdf\\Size::A4 orientation : Drewlabs\\Dompdf\\Orientation::LANDSCAPE, Drewlabs\\Dompdf\\Orientation::PORTRAIT

```
// ...
$pdf = DomPdf([/* DOMPdf otpions */]);

$pdf->constraints(Drewlabs\Dompdf\Size::A4, \Drewlabs\Dompdf\Orientation::PORTRAIT);
```

- Print PDF content

The library provides developper with a method to return the generated PDF string through the `Dompdf::print` API. To print a raw document:

```
$pdf = DomPdf([/* DOMPdf otpions */]);

$pdf->print(); // Returns a raw string
```

- Http response

The `Dompdf::download(string $name)` API allows developper to create a response object from the PDF content.

```
$pdf = DomPdf([/* DOMPdf otpions */]);
// It's a late content read, meaning it does not send content to request client unless
// user code manually call send() on the response object
$response = $pdf->download(); // Symfony HTTP response

// To send the response to request client, developper must call $response->send() method
$response->prepare(new Request::createFromGlobals())->send();
```

- Streaming content

The library provides developper with method to streaming pdf content to request client.

```
$pdf = DomPdf([/* DOMPdf otpions */]);

$pdf->stream(); // Internally uses PHP echo method to write to the output buffer
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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

Unknown

Total

1

Last Release

1277d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48c4973d500c7f4233d5ceacab51a57208d5fb60b0f95ae60264cf92380d0534?d=identicon)[azandrew-sidoine](/maintainers/azandrew-sidoine)

---

Top Contributors

[![azandrew-sidoine](https://avatars.githubusercontent.com/u/23530515?v=4)](https://github.com/azandrew-sidoine "azandrew-sidoine (26 commits)")

---

Tags

pdfdom

### Embed Badge

![Health badge](/badges/drewlabs-php-dompdf/health.svg)

```
[![Health](https://phpackages.com/badges/drewlabs-php-dompdf/health.svg)](https://phpackages.com/packages/drewlabs-php-dompdf)
```

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[sensiolabs/gotenberg-bundle

A Symfony bundle that provides seamless integration with Gotenberg for generating PDFs and screenshots from various sources (HTML, Markdown, Office documents, URLs) with a clean, builder-based API.

210210.4k2](/packages/sensiolabs-gotenberg-bundle)[consoletvs/invoices

Generate PDF invoices for your customers in laravel

455275.5k](/packages/consoletvs-invoices)[nucleos/dompdf-bundle

This bundle provides a wrapper for using dompdf inside symfony.

54882.8k1](/packages/nucleos-dompdf-bundle)[danielboendergaard/phantom-pdf

A Package for generating PDF files using PhantomJS

72467.9k](/packages/danielboendergaard-phantom-pdf)[dino/dompdf-module

A Zend Framework 2 module for incorporating DOMPDF support.

61465.1k8](/packages/dino-dompdf-module)

PHPackages © 2026

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