angusm73 / unoconv
Convert documents using unoconv inside a Laravel application.
v1.4
2019-06-06 01:23 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ~5.1
This package is not auto-updated.
Last update: 2024-11-16 02:01:27 UTC
README
A Laravel wrapper for unoconv.
Installation
Install this package through Composer.
Add this to your composer.json
dependencies:
Using Laravel 5.2+
"require": { "angusm73/unoconv": "dev-master" }
Run composer install
to download the required files.
Next you need to add the service provider to config/app.php
'providers' => [ ... Angusm73\Unoconv\UnoconvServiceProvider::class ]
Set up the facade. Add the reference in config/app.php
to your aliases array.
'aliases' => [ ... 'Unoconv' => Angusm73\Unoconv\Facades\Unoconv::class, ]
Publish the config
php artisan vendor:publish --provider="Angusm73\Unoconv\UnoconvServiceProvider" --tag="config"
Usage
File conversion
# Convert the file to /file.pdf Unoconv::file('/file.pptx')->to('pdf');
# Convert the file and save it in a different location /new/location/file.pdf Unoconv::file('/file.pptx')->to('/new/location/file.pdf');
Chaining multiple conversions
# Convert the file to /file.pdf and /file.jpg Unoconv::file('/file.pptx')->to(['pdf', 'jpg]);
# Convert the file to /file.pdf and /preview/file.jpg Unoconv::file('/file.pptx')->to(['pdf', '/preview/file.jpg]);
Non-blocking conversion using a queue
To use queues you will need have set-up the default laravel queue listener.
Unoconv::file('/file.pptx')->queue('pdf');
# You can also specify the queue. Unoconv::file('/file.pptx')->onQueue('image-converter', 'pdf');
Dispatch new job after conversion is done
Unoconv::file('/file.pptx')->after((new AfterConversionJob()))->to('pdf');