mtcextendee / mautic-badge-generator-bundle
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 3
Open Issues: 2
Type:mautic-plugin
Requires
- mautic/composer-plugin: ^1.0
- setasign/fpdi-tcpdf: ^2.0
README
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.
Features
- Add with custom text slots to PDF
- Custom contact fields
- Custom font-size, color and position
- Add barcode to PDF
- Require https://github.com/mtcextendee/mautic-barcode-generator-bundle
- Any custom contact field to generate Barcode
- Custom position and width/height of barcode
- Add QRcode to PDF
- Require https://github.com/mtcextendee/mautic-barcode-generator-bundle
- Any custom contact field to generate QRcode
- Custom position and width/height of barcode, color etc.
- Token support - use link to badge in email/page (
{badge=1}
) - Add to stage after download generate PDF
- Generate custom PDF for each contacts from contact list
- Display badge generator bundle just for contact with certain tags
Installation
Installation from command line:
composer require mtcextendee/mautic-badge-generator-bundle
php app/console mautic:plugins:reload
Manual installation is not allowed because plugins depend on another setasign/fpdi-tcpdf, which is installed automatically from command line.
Setup
Just go to plugins and enable new BadgeGenerator integration. Then you should see new column in left menu.
Generate PDF
In contact list
Before
After
API
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:
- If badge exist for contact
$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/
- If badge or contact not exist:
$response['errors']