Download the PHP package iwasherefirst2/pretty-pdf without Composer
On this page you can find all versions of the php package iwasherefirst2/pretty-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iwasherefirst2/pretty-pdf
More information about iwasherefirst2/pretty-pdf
Files in iwasherefirst2/pretty-pdf
Package pretty-pdf
Short Description Create a beautiful invoice with PHP
License MIT
Informations about the package pretty-pdf
PrettyPdf
This package helps you to create invoices and letters with PHP with UTF8 support.
The invoice looks like this:
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!
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:
Required PHP Version
Min PHP Version | Pretty PDF Version |
---|---|
PHP 7.4 | v.2.0 |
PHP 5 | v.1.1.0 |
Installation
Install via composer:
Example
Methods
Most important function is the output function 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.
In addition, the following functions are available:
Methods | Description |
---|---|
localize('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' => 'Today', 'Invoice' => 'I 2020-03-22', 'Tax-Number' => '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 invoice |
paymentInfo($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 date |
foldMarker() | Add a mark where to fold the letter |
tableBox(string $title, array $rows) | Add a headline and a tablein the top right corner |
text(string $text) | A text. This is when you want to use this class for a letter. Use "\n" in your string for returns |
How can I add my own styling?
Simply create a class that extends PrettyPdf\Partials\Drawable
.
Next, you need to register your class or classes to PrettyPdf
:
Now you can use the method by simply calling the classname on $prettyPdf
:
How does testing work?
A pdf will be created during the test and compared to an existing pdf. Since comparing pdf documents is not feasible, since the file itself contain meta-data that are always distinct, our tests convert the pdf to an image and compare the images.
Thus, we require for testing the ImageMagic and GD library. To make your life easier, this package ships with a docker file.
You may use it like this:
Next, go inside the container to install composer and run phpunit:
Create a test class that extends from BeautyBillTestCase.
Here is an example:
When storeOnly
is set to true, it will not compare pdfs but
just store the pdf in Test.pdf
or whatever name you put in the method
assertEqualPDFs
. Once the pdf looks as you want to have it,
you may remove the storeOnly
line.