mykemeynell / filepreview
There is no license information available for the latest version (v1.0.1) of this package.
Library for generating file previews.
v1.0.1
2020-03-02 13:50 UTC
Requires
- nesbot/carbon: ^2.30
- phpoffice/phpword: ^0.17.0
- symfony/http-foundation: ^5.0
- tecnickcom/tcpdf: ^6.3
Requires (Dev)
- larapack/dd: ^1.1
This package is auto-updated.
Last update: 2024-12-04 21:24:53 UTC
README
Generate preview images for file types.
Installation with Composer
composer require mykemeynell/filepreview
Usage
$fileName = '/path/to/file.pdf'; $preview = mykemeynell\FilePreview\FilePreview::fromPath($fileName); echo $preview->preview()->stream();
FilePreview::preview()
Actions the conversion and prepares headers for output.
FilePreview::stream()
Sets appropriate headers prepared in FilePreview::stream()
and outputs
the content.
Custom Handlers
If you wish to change how MIME types are handled, then you can use the
FilePreview::addHandler($mime, $handler)
method.
$handler
can accept two parameters
- [Parameter 0] Instance of
FilePreview
. - [Parameter 1] Instance of
mykemeynell\FilePreview\FileSystem\File::class
relating to the given file path.
FilePreview::addHandler('application/pdf', function ($preview, $file) { /** @var \mykemeynell\FilePreview\FilePreview $preview */ /** @var \mykemeynell\FilePreview\FileSystem\File $file */ // $content = ...= $preview->setContentTypeHeader('image/jpg'); $preview->setContent($content); return $preview; });