PHP code example of bogdankharchenko / laravel-pdfmill
1. Go to this page and download the library: Download bogdankharchenko/laravel-pdfmill library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bogdankharchenko / laravel-pdfmill example snippets
use BogdanKharchenko\PdfMill\MergeSource;
$pdf = PdfMill::merge([
MergeSource::file($request->file('contract')),
MergeSource::file($request->file('id_scan')), // images become pages
'templates/terms.pdf', // an R2 key or a URL
])->store();
use BogdanKharchenko\PdfMill\Data\InfoResponse;
use BogdanKharchenko\PdfMill\PdfSource;
$info = PdfMill::info('uploads/form.pdf'); // a LockedInfoResponse if it needs a password
if ($info instanceof InfoResponse) {
foreach ($info->form->fields as $field) {
echo "{$field->name} ({$field->type->value}): ".json_encode($field->value);
}
}
$text = PdfMill::text(PdfSource::file($path, password: 'secret'))->pages[0]->text;