https://github.com/esbenp/pdf-bot-laravel
🤖 Laravel integration for pdf-bot. A Node microservice for generating PDFs using headless Chrome
https://github.com/esbenp/pdf-bot-laravel
Last synced: about 2 months ago
JSON representation
🤖 Laravel integration for pdf-bot. A Node microservice for generating PDFs using headless Chrome
- Host: GitHub
- URL: https://github.com/esbenp/pdf-bot-laravel
- Owner: esbenp
- License: mit
- Created: 2017-08-12T14:30:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T17:38:10.000Z (5 months ago)
- Last Synced: 2025-03-24T17:54:44.880Z (3 months ago)
- Language: PHP
- Homepage: https://github.com/esbenp/pdf-bot
- Size: 14.6 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 🤖 pdf-bot-laravel
Laravel integration for [pdf-bot, a Node microservice for generating PDFs using headless Chrome](https://github.com/esbenp/pdf-bot).
## Installation
```bash
composer require optimus/pdf-bot 0.1.*
```Add the service provider to `config/app.php`
```php
// ... other service providers
Optimus\PdfBot\PdfBotServiceProvider::class,
```Publish the config file.
```bash
php artisan vendor:publish provider="Optimus\PdfBot\PdfBotServiceProvider"
```You also need to create a controller for receiving webhooks.
```php
post('/webhooks/pdf', '\Infrastructure\Webhooks\Controllers\PdfController@receive');
```Now you can access `pdf-bot` using
```bash
$pdfBot = app()->make(\Optimus\PdfBot\PdfBot::class);
```or by adding the including facade to your facades.
## Configuration
As a minimum you should change the `server` and `secret` parameters in `config/optimus.pdfbot.php`.
```php
'secret-used-for-generating-signature','server' => 'http://url-to-pdf-bot-server',
'header-namespace' => 'X-PDF-'
];
```## Usage example
Now you are ready to generate PDF's. Start by pushing a URL to the PDF server for generation.
```php
$pdfBot = app()->make(\Optimus\PdfBot\PdfBot::class);
$pdfBot->push('https://invoices.traede.com/1', [
'type' => 'invoice',
'id' => 1
]);
```Now this will be added to your PDF queue. At some point your PDF controller method (`onPdfReceived`) will receive a request with the path to the file. In your controller you can decide what to do with it.
```php
pdf = $s3['path']['key'];
$invoice->save();
break;
}
}
}
```Now the invoice's location is saved on the correct invoice.
## Issues
[Please report issues to the issue tracker](https://github.com/esbenp/pdf-bot/issues/new)
## License
The MIT License (MIT). Please see [License File](https://github.com/esbenp/pdf-bot/blob/master/LICENSE) for more information.