PHPackages                             lianhua/superpdf - 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. lianhua/superpdf

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

lianhua/superpdf
================

A simple library to manipulate PDF files

1.1.5(2y ago)0369GPL-3.0PHP

Since May 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Nevermille/PHP-SuperPDF)[ Packagist](https://packagist.org/packages/lianhua/superpdf)[ RSS](/packages/lianhua-superpdf/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (6)Versions (9)Used By (0)

PHP-SuperPDF
============

[](#php-superpdf)

A simple library to manipulate PDF files

[![Build Status](https://camo.githubusercontent.com/5d5e5b3d3847fc554ef418c4057a058a115baefb8dfdaa0d34174240ffeecbaa/68747470733a2f2f7472617669732d63692e636f6d2f4e657665726d696c6c652f5048502d53757065725044462e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Nevermille/PHP-SuperPDF) [![BCH compliance](https://camo.githubusercontent.com/3cb2bc9f6aa0b251ce0c2358f8f637ea9742b503945e5bed125558a59d611f8d/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f4e657665726d696c6c652f5048502d53757065725044463f6272616e63683d6d6173746572)](https://bettercodehub.com/) [![License: GPL v3](https://camo.githubusercontent.com/48bf9b56d44f38db53ce21294cf0b9487d0a3734ab3ba1fe4c69858ae20db2c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://www.gnu.org/licenses/gpl-3.0)

Overview
--------

[](#overview)

A simple library to manipulate PDF files in PHP

Compatibility
-------------

[](#compatibility)

This library has been tested for PHP 7.3 and higher. Functions relying on TCPDF don't work on PHP 8 at the moment!

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

[](#installation)

Just use composer in your project:

```
composer require lianhua/superpdf

```

If you don't use composer, clone or download this repository, all you need is inside the src directory, you'll need the FPDI library.

Usage
-----

[](#usage)

### Open a PDF file

[](#open-a-pdf-file)

You can open a PDF document with a new SuperPDF:

```
$pdf = new SuperPDF("/path/to/pdf/file");
```

### Count the pages

[](#count-the-pages)

You can ask for the pages count:

```
$pagesCount = $pdf->getPageCount();
```

### Extract pages

[](#extract-pages)

#### Range

[](#range)

If you want to extract a range of pages into a pdf file:

```
$pdf->extractPageRange(3, 7, "path/to/pdf/output");
```

#### List

[](#list)

If you want to extract a list of pages into a pdf file:

```
$pdf->extractPageList([1, 3, 6, 8, 9], "path/to/pdf/output");
```

### Insert a PDF document

[](#insert-a-pdf-document)

If you want to insert a PDF file's contents into the document:

```
$pdf->insertPages("/path/to/pdf/to/insert", 5); // Inserts the PDF at page 5
$pdf->insertPages("/path/to/pdf/to/insert", SuperPDF::AFTER_EACH_PAGE); // Inserts the PDF after each page
$pdf->insertPages("/path/to/pdf/to/insert", SuperPDF::AFTER_ODD_PAGES); // Inserts the PDF after odd pages
$pdf->insertPages("/path/to/pdf/to/insert", SuperPDF::AFTER_EVEN_PAGES); // Inserts the PDF after even pages
$pdf->insertPages("/path/to/pdf/to/insert", SuperPDF::AT_THE_END); // Inserts the PDF after the last page
```

If you don't want to overwrite the document, you can give an output path:

```
$pdf->insertPages("/path/to/pdf/to/insert", 5, "/path/to/output");
```

### Add a background

[](#add-a-background)

If you want to add a background on your document:

```
$pdf->addBackground("/path/to/background/pdf", 5); // Adds a background on page 5
$pdf->addBackground("/path/to/background/pdf", SuperPDF::ON_LAST_PAGE); // Adds a background on last page
$pdf->addBackground("/path/to/background/pdf", SuperPDF::ON_ODD_PAGES); // Adds a background on odd pages
$pdf->addBackground("/path/to/background/pdf", SuperPDF::ON_EVEN_PAGES); // Adds a background on even pages
$pdf->addBackground("/path/to/background/pdf", SuperPDF::ON_EACH_PAGE); // Adds a background on each page
```

Like before, if you don't want to overwrite the document, you can give an output path:

```
$pdf->addBackground("/path/to/background/pdf", 5, "/path/to/output");
```

### Write text

[](#write-text)

If you want to write som text on the document:

```
$params = [
    "font" => "arial", // Font family
    "color" => ["r" => 30, "g" => 30, "b" => 30], // Font color
    "pos" => ["x" => 10, "y" => 20], // Text position
    "size" => 15 // Font size
];

$pdf->writeText("Some text", $params, 5); // Writes a text on page 5
$pdf->writeText("Some text", $params, SuperPDF::ON_LAST_PAGE); // Writes a text on last page
$pdf->writeText("Some text", $params, SuperPDF::ON_ODD_PAGES); // Writes a text on odd pages
$pdf->writeText("Some text", $params, SuperPDF::ON_EVEN_PAGES); // Writes a text on even pages
$pdf->writeText("Some text", $params, SuperPDF::ON_EACH_PAGE); // Writes a text on each page
```

Like before, if you don't want to overwrite the document, you can give an output path:

```
$pdf->writeText("Some text", $params, 5, "/path/to/output");
```

### Draw an image

[](#draw-an-image)

If you want to draw an image (PNG, JPG, GIF or SVG) on the document:

```
$params = [
    "x" => 30, // The X position
    "y" => 50, // The Y position
    "w" => 60 // The width (you can also use h)
];

$pdf->drawImage("/path/to/image/file", $params, 5); // Draws an image on page 5
$pdf->drawImage("/path/to/image/file", $params, SuperPDF::ON_LAST_PAGE); // Draws an image on last page
$pdf->drawImage("/path/to/image/file", $params, SuperPDF::ON_ODD_PAGES); // Draws an image on odd pages
$pdf->drawImage("/path/to/image/file", $params, SuperPDF::ON_EVEN_PAGES); // Draws an image on even pages
$pdf->drawImage("/path/to/image/file", $params, SuperPDF::ON_EACH_PAGE); // Draws an image on each page
```

Like before, if you don't want to overwrite the document, you can give an output path:

```
$pdf->drawImage("/path/to/image/file", $params, 5, "/path/to/output");
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Recently: every ~246 days

Total

7

Last Release

960d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38858480?v=4)[Camille Nevermind](/maintainers/Nevermille)[@nevermille](https://github.com/nevermille)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lianhua-superpdf/health.svg)

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

###  Alternatives

[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k81.2M543](/packages/mpdf-mpdf)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M517](/packages/shopware-core)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4275.2M26](/packages/horstoeko-zugferd)[iio/libmergepdf

Library for merging multiple PDFs

40814.2M19](/packages/iio-libmergepdf)

PHPackages © 2026

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