ghostfly / pdf-forms-filler
Fill Acrobat forms easily using pure PHP ! 💪
Installs: 2 141
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 3
Forks: 6
Open Issues: 0
Requires
- php: >=7.1.0
- setasign/fpdf: ^1.8
- setasign/fpdi: ^2.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2023-06-27 13:20:17 UTC
README
Fill Acrobat forms easily using pure PHP ! 💪
Requirements
- PHP >= 7.1.0
Install :
$ composer require ghostfly/pdf-forms-filler
Example :
- clone repository
- go to example folder
- composer install
- run index.php
Usage :
You need to do a PDF Form with Acrobat, and the string to convert is given by this page :
Use Converter who gives you a JSON Array containing fields with locations / page, in a form usable by the Generator
$converter = new Converter($string);
$converter->getPagesWithFieldsCount();
$json = $converter->formatFieldsAsJson($pages);
echo json;
Use PDF Generator with one array containing every field with id -> value And one array containing every field with id -> llx, lly, urx, ury, page
$pdfGenerator = new PDFGenerator($coords, $data, 'P', 'pt', 'A4');
$pdfGenerator->start($original, $dest);
If your original PDF is not handled by fpdf, you can convert it using this service :
Convert PDF with "Acrobat 4.0 (PDF 1.3)"
Don't care about form fields on file to send to generator, the locations are determined using the latest PDF format.
If you need a full example : index.php.
Tests
$ ./vendor/bin/phpunit tests
Code coverage
$ ./vendor/bin/phpunit tests --coverage-text --coverage-clover build/logs/clover.xml
Done. ;)