PHPackages                             quickshiftin/php-pdf-invoice - 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. quickshiftin/php-pdf-invoice

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

quickshiftin/php-pdf-invoice
============================

Generate PDF files for your application's invoices with PHP

1.10.0(8y ago)162077[1 issues](https://github.com/quickshiftin/php-pdf-invoice/issues)[1 PRs](https://github.com/quickshiftin/php-pdf-invoice/pulls)OSL-3.0PHP

Since Aug 18Pushed 2y ago2 watchersCompare

[ Source](https://github.com/quickshiftin/php-pdf-invoice)[ Packagist](https://packagist.org/packages/quickshiftin/php-pdf-invoice)[ RSS](/packages/quickshiftin-php-pdf-invoice/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

PHP PDF Invoice
===============

[](#php-pdf-invoice)

This project uses a PDF invoice generator extracted from Magento for general use via Composer. You can easily integrate your existing domain model and start generating PDF invoices that look like this:

[![Example Invoice PDF](https://camo.githubusercontent.com/10973b6065807942cf0ad3d1fd711ff8c8fcf8d982a677e098cece4d114ddfeb/687474703a2f2f693238392e70686f746f6275636b65742e636f6d2f616c62756d732f6c6c3233382f717569636b7368696674696e2f7068702d7064662d696e766f6963652d6578616d706c655f7a70737769756d6d3974672e706e67)](https://camo.githubusercontent.com/10973b6065807942cf0ad3d1fd711ff8c8fcf8d982a677e098cece4d114ddfeb/687474703a2f2f693238392e70686f746f6275636b65742e636f6d2f616c62756d732f6c6c3233382f717569636b7368696674696e2f7068702d7064662d696e766f6963652d6578616d706c655f7a70737769756d6d3974672e706e67)

Features
--------

[](#features)

- Generate Invoice PDF documents
- Integrate your domain model easily by implementing Order and OrderItem interfaces
- Composer distribution
- Change background and font colors, font types, line color and provide custom logo
- Automatically create multiple pages based on number of line items

Install via Composer
--------------------

[](#install-via-composer)

`./composer.phar require quickshiftin/php-pdf-invoice`

Usage
-----

[](#usage)

### Integration boilerplate - connecting your existing domain model to the generator

[](#integration-boilerplate---connecting-your-existing-domain-model-to-the-generator)

To integrate your existing application's orders, simply provide two classes that `implement` `Quickshiftin\Pdf\Invoice\Spec\Order` and `Quickshiftin\Pdf\Invoice\Spec\OrderItem`

#### OrderItem interface implementation

[](#orderitem-interface-implementation)

```
namespace MyApp;
use Quickshiftin\Pdf\Invoice\Spec\OrderItem;

// Implement the Order Item methods below
class MyOrderItem interface implements OrderItem
{
    /**
     * The name or description of the product
     * @return string
     */
    public function getName();

    /**
     * The 'SKU' or unique identifier for your product
     * @return string
     */
    public function getSku();

    /**
     * The quantity sold
     * @return int
     */
    public function getQuantity();

    /**
     * The price per unit
     * @return float
     */
    public function getPricePerUnit();

    /**
     * The price including tax
     * @return flaot
     */
    public function getPrice();

    /**
     * The sales tax amount in dollars
     * @return float
     */
    public function getSalesTaxAmount();
}
```

#### Order interface implementation

[](#order-interface-implementation)

```
use Quickshiftin\Pdf\Invoice\Spec\Order;

// Implement the order methods below
class MyOrder implements Order
{
    /**
     * Get the sub-total, eclusive of shipping and tax.
     * @return float
     */
    public function getPriceBeforeShippingNoTax();

    /**
     * Get the shipping charge if any
     * @return float
     */
    public function getCustomerShipCharge();

    /**
     * Get the sales tax amount, eg .08 for 8%
     * @return float
     */
    public function getSalesTaxAmount();

    /**
     * Get the total cost including shipping and tax
     * @return float
     */
    public function getTotalCost();

    /**
     * Get the full billing address for the customer
     * @return string
     */
    public function getFullBillingAddress();

    /**
     * Get the payment method, EG COD, Visa, PayPal etc
     * @return string
     */
    public function getPaymentMethod();

    /**
     * Get the full shipping address for the order
     * @return string
     */
    public function getFullShippingAddress();

    /**
     * Get the name of the shipping method, EG UPS, FedEx, etc
     * @return string
     */
    public function getShippingMethodName();

    /**
     * Get an array of OrderItem objects
     * @note This should return an array of instances of a class where you implement Quickshiftin\Pdf\Invoice\Spec\OrderItem
     * @return array
     */
    public function getOrderItems();

    /**
     * Get the id of the order
     * @return int|string
     */
    public function getOrderId();

    /**
     * Get the date of the sale
     * @return DateTime
     */
    public function getSaleDate();
}
```

### Implementation suggestion

[](#implementation-suggestion)

Since these are `interface`s, you can create a new class that wraps your existing OrderItem objects. If there are no name collisions you could also consider implementing directly on your existing OrderItem class.

### Building &amp; Styling your Invoice PDFs

[](#building--styling-your-invoice-pdfs)

This system uses [`Zend_Pdf`](https://framework.zend.com/manual/1.10/en/zend.pdf.html) (from ZF1) under the hood. The package provides `Quickshiftin\Pdf\Invoice\Factory` which is a wrapper for instantiating classes from `Zend_Pdf`. You'll use these objects to customize the appearance of your PDFs.

We also assume you have an instance of an order object which implements `Quickshiftin\Pdf\Invoice\Spec\Order` as described above that is stored in a variable called `$myOrder`.

```
use Quickshiftin\Pdf\Invoice\Invoice as PdfInvoice;
use Quickshiftin\Pdf\Invoice\Factory as InvoiceFactory;

$oInvoiceFactory = new InvoiceFactory();
$oInvoicePdf     = new PdfInvoice();

// Configure fonts - just put ttf font files somewhere your project can access them
$oInvoicePdf->setRegularFontPath(__DIR__ . '/../assets/Arial.ttf');
$oInvoicePdf->setBoldFontPath(__DIR__ . '/../assets/Arial Bold.ttf');
$oInvoicePdf->setItalicFontPath(__DIR__ . '/../assets/Arial Italic.ttf');

// Set Colors
$red    = '#d53f27';
$yellow = '#e8e653';

// Title section of invoice
// Background color for title section of invoice, the default is white
$oInvoicePdf->setTitleBgFillColor($oInvoiceFactory->createColorHtml($yellow));
$oInvoicePdf->setTitleFontColor($oInvoiceFactory->createColorHtml('black'));

// Header sections of invoice
$oInvoicePdf->setHeaderBgFillColor($oInvoiceFactory->createColorHtml($red));
$oInvoicePdf->setBodyHeaderFontColor($oInvoiceFactory->createColorHtml('white'));

// Body section of invoice
$oInvoicePdf->setBodyFontColor($oInvoiceFactory->createColorHtml('black'));

// Line color of invoice
$oInvoicePdf->setLineColor($oInvoiceFactory->createColorGrayscale(0));

// Configure logo
$oInvoicePdf->setLogoPath(__DIR__ . '/../assets/fake-logo.jpg');

// Build the PDF
// $oPdf is an instance of Zend_Pdf
$oPdf = $oInvoicePdf->getPdf($myOrder);

// A string rendition, you could echo this to the browser with headers to implement a download
$pdf = $oPdf->render();

// You can also simply save it to a file
file_put_contents('/tmp/test.pdf', $pdf);
```

Notes
-----

[](#notes)

You can look at the test directory for usage insights. Issues and PRs welcome!

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

2964d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/96733?v=4)[Nathan Nobbe](/maintainers/quickshiftin)[@quickshiftin](https://github.com/quickshiftin)

---

Top Contributors

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

---

Tags

invoicepdfphp

### Embed Badge

![Health badge](/badges/quickshiftin-php-pdf-invoice/health.svg)

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

###  Alternatives

[pestphp/pest

The elegant PHP Testing Framework.

11.6k67.7M19.3k](/packages/pestphp-pest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2222.6M322](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30300.1k7](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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