Simple builder for PDF files
Requires PHP >= 7.0.
<?php
use PdfBuilder\Format\A4;
$builder = new PdfBuilder(new A4());
$pdf = $builder
->write('Hello World!')
->build();
This example create pdf file with one string 'Hello World!'
Add text
$pdf = $builder
->write('My name')
->build();
Set new font for text writing. Available fonts are in the 'src/Fonts' directory
$pdf = $builder
->setFont(new Courier(12))
->write('Hello')
->setFont(new CourierBold(20))
->write('World')
->build();
Add newline manually. If the text takes more than a line, then a new one is added automatically
$pdf = $builder
->write('Hello')
->newLine()
->write('World')
->build();
Add new page manually. If the text takes more than a page, then a new one is created automatically
$pdf = $builder
->write('Hello')
->newPage()
->write('World')
->build();
Add new image from file. Supported formats: jpg
$pdf = $builder
->drawImage('cat.jpg')
->build();
Change pen position right dx
and down dy
$pdf = $builder
->write('Hello')
->move(40, 50)
->write('World')
->build();
Set pen position
$pdf = $builder
->write('Hello')
->setPosition(100, 200)
->write('World')
->build();
Run command
phpunit tests