Badge PDF generator
Plugin from Mautic Extension family (https://mtcextendee.com)
Download 7 ultimate free Mautic email themes https://mtcextendee.com/themes/
In general, plugin modify any PDF and add new text custom slots and barcode to PDF. Useful for your events.
{badge=1}
)composer require mtcextendee/mautic-badge-generator-bundle
php app/console mautic
reload
Manual installation is not allowed because plugins depend on another setasign/fpdi-tcpdf, which is installed automatically from command line.
Just go to plugins and enable new BadgeGenerator integration. Then you should see new column in left menu.
In contact list
Library: https://github.com/mautic/api-library
Hook
$api = new \Mautic\Api\Api($auth, $apiUrl);
$contactId = 1;
$badgeId = 2;
$response = $api->makeRequest(sprintf("badge/generator/%d/%d", $contactId, $badgeId));
Example for Basic Authorization:
// Bootup the Composer autoloader
include __DIR__.'/vendor/autoload.php';
use Mautic\Auth\ApiAuth;
$apiUrl = 'http://mautic.site';
$settings = [
'userName' => 'admin',
'password' => 'mautic',
];
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings, 'BasicAuth');
$api = new \Mautic\Api\Api($auth, $apiUrl);
$contactId = 1;
$badgeId = 2;
$response = $api->makeRequest(sprintf("badge/generator/%d/%d", $contactId, $badgeId));
if (isset($response['pdf'])) {
$result = base64_decode($response['pdf']);
// Write on file
file_put_contents('test.pdf', $result);
echo 'PDF created';
} elseif (isset($response['errors'][0]['message'])) {
echo $response['errors'][0]['message'];
}
Response:
$response['pdf'] = 'base64 encode of PDF content';
You need base64decode of PDF content and then process it (dispay or save..). For more info check: https://selectpdf.com/web-html-to-pdf-rest-api-for-php-samples/
$response['errors']