eboost/unoconv

此包已被弃用且不再维护。未建议替代包。

使用 unoconv 转换文档。

1.0 2016-11-01 16:30 UTC

This package is auto-updated.

Last update: 2021-02-16 11:49:25 UTC


README

一个作为 webservice 的 unoconv Laravel 包装器。有关更多详细信息,请参阅 Convert

安装

通过 Composer 安装此包。

将以下内容添加到您的 composer.json 依赖项中

使用 Laravel 5.2+

"require": {
   "eboost/unoconv": "dev-master"
}

运行 composer install 下载所需文件。

接下来,您需要将服务提供者添加到 config/app.php

'providers' => [
    ...
    Eboost\Unoconv\UnoconvServiceProvider::class
]

设置 facade。在 config/app.php 中将引用添加到您的别名数组中。

'aliases'  => [
    ...
    'Unoconv' => Eboost\Unoconv\Facades\Unoconv::class,
]

发布配置

php artisan vendor:publish --provider="Eboost\Unoconv\UnoconvServiceProvider" --tag="config"

用法

文件转换

# 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');

链式多个转换

# 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]);

使用队列进行非阻塞转换

要使用队列,您需要已设置默认的 Laravel 队列监听器。

Unoconv::file('/file.pptx')->queue('pdf');
# You can also specify the queue.

Unoconv::file('/file.pptx')->onQueue('image-converter', 'pdf');

转换完成后调度新任务

Unoconv::file('/file.pptx')->after((new AfterConversionJob()))->to('pdf');