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

ActiveLibrary

iwasherefirst2/pretty-pdf
=========================

Create a beautiful invoice with PHP

v2.1.0(3y ago)1225↓100%1MITPHPPHP &gt;=7.4

Since Mar 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/iwasherefirst2/pretty-pdf)[ Packagist](https://packagist.org/packages/iwasherefirst2/pretty-pdf)[ RSS](/packages/iwasherefirst2-pretty-pdf/feed)WikiDiscussions main Synced today

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

PrettyPdf
=========

[](#prettypdf)

This package helps you to create invoices and letters with PHP with UTF8 support.

The invoice looks like this: [![image](https://user-images.githubusercontent.com/1765602/112662390-ed54f900-8e57-11eb-905f-957982939b81.png)](https://user-images.githubusercontent.com/1765602/112662390-ed54f900-8e57-11eb-905f-957982939b81.png)

The best thing about this package is that the invoices look absolutly fantastic and in addition, the address of your letter/invoice fully fits your envelope window! [![20210326_173723](https://user-images.githubusercontent.com/1765602/112665009-e11e6b00-8e5a-11eb-8035-ba053b6ec169.jpg)](https://user-images.githubusercontent.com/1765602/112665009-e11e6b00-8e5a-11eb-8035-ba053b6ec169.jpg)

The default format is A4. If you need a different format, just the FPDF standard methods.

Each section of the invoice relates to a method: [![image](https://user-images.githubusercontent.com/1765602/112663289-f0041e00-8e58-11eb-81cd-2826b0780f4b.png)](https://user-images.githubusercontent.com/1765602/112663289-f0041e00-8e58-11eb-81cd-2826b0780f4b.png)

Required PHP Version
--------------------

[](#required-php-version)

Min PHP VersionPretty PDF VersionPHP 7.4v.2.0PHP 5v.1.1.0Installation
------------

[](#installation)

Install via composer:

```
composer require iwasherefirst2/pretty-pdf

```

Example
-------

[](#example)

```
    $item = new \PrettyPdf\Partials\Invoice\Data\Item();

    $item->description = 'A new currency';
    $item->quantity = 5;
    $item->name = 'Bitcoin';
    $item->unitPrice = 2031.23;

    $paymentInfoDate = new \PrettyPdf\Partials\Invoice\Data\PaymentInfo();

    $paymentInfoDate->title = 'A really good title';
    $paymentInfoDate->description = 'A long description comes in here';
    $paymentInfoDate->bank = 'ING';
    $paymentInfoDate->bic = 'BICXXX';
    $paymentInfoDate->iban = 'DE42 4242 4242 4242 4242 24';
    $paymentInfoDate->name = 'Beauty Bill Creator';

    $bill = new \PrettyPdf\PrettyPdf();

    $bill->logo('/path/to/your/logo.png')
            ->headerInfoBox(['1600 Pennsylvania Ave NW', 'Washington', 'DC 20500', 'United States', 'Beauty Bill Package', 'info@drnielsen.de'])
            ->returnAddress('Dr. Schwadam, Schwinterfeldschraße 99, 10777 Berlin, Germany')
            ->receiverAddress(['Michael Jackson', 'Colorado Hippo Zoo', '5225 Figueroa Mountain Rd', 'Los Olivos', 'CA 93441', 'United States'])
            ->invoiceBox(['Date' => 'Today', 'Invoice' => 'I 2020-03-22', 'Tax-Number' => '18/455/12345'])
            ->items([$item], 19)
            ->paymentInfo($paymentInfoDate)
            ->additionalNote('Optioanl note. Nothing important here.')
            ->output('/path/where/you/want/to/store/file.pdf');

```

Methods
-------

[](#methods)

Most important function is the [output function](http://www.fpdf.org/en/doc/output.htm)which renders the pdf, either by saving it as a file or by viewing the PDF in the browser, or save it as a string.

You can call all other functions from [FPDF](http://www.fpdf.org).

In addition, the following functions are available:

MethodsDescriptionlocalize('en')Set language of document. Currently only English (en) and German (de) is supported. Feel free to add more languages to the repository, merge requests are welcome.setLocalizationPath(/full/path/)Full path to your custom localization files, if you don't want to use the repositorie ones.logo(/full/path/logo.png)Adds the logo to your pdf to the top left corner.receiverAdress(\['Max Musterman', 'Victoria Luise Platz 97', '10777 Berlin', 'Germany')Address of document. Height will be adjustet so that it fits on the envelope. Each entry of the array has its own line.returnAddress('My home address, Germany 121212')Return address. Will be written as single line above address.invoiceBox(\['Date' =&gt; 'Today', 'Invoice' =&gt; 'I 2020-03-22', 'Tax-Number' =&gt; '18/455/12345'\])Will add a little box with heading "Invoice" right from the address.headerInfoBox(\['Max Mastermind', 'Your Adress', 'New York'\])Your address in the top right corner.items(\[$itemA, $itemB, $itemC\], $vat)Receives an array (or any iterable object) of `\BeautyBill\Partials\Body\Data\Item` objects and the VAT in percent. For example, in Germany we have 19% VAT, so 19 has to be passed as a parameter. Each represents a row of your invoicepaymentInfo($paymentInfoData)Receives an object of `\BeautyBill\Partials\Body\Data\PaymentInfo`. This will create an info how to pay on the lower left side.additionalNote(string $text)Showes a note for special rules that apply to invoice. Note appears on the lower right side.date(string $text)Adds a date to the left side, usefull for letters. If no argument is passed, show current datefoldMarker()Add a mark where to fold the lettertableBox(string $title, array $rows)Add a headline and a tablein the top right cornertext(string $text)A text. This is when you want to use this class for a letter. Use "\\n" in your string for returnsHow can I add my own styling?
-----------------------------

[](#how-can-i-add-my-own-styling)

Simply create a class that extends `PrettyPdf\Partials\Drawable`.

```
