redor/silverstripe-simple-pdf-preview
最新稳定版本:0.0.2
Composer 安装命令:
composer require redor/silverstripe-simple-pdf-preview
包简介
Simple Pdf Preview Extension for SilverStripe CMS
README 文档
README
Simple Pdf Preview Extension for SilverStripe CMS
Create Jpg Preview Images of Pdf files on the fly.
Install
Via Composer
{
"require": {
"ivoba/silverstripe-simple-pdf-preview": "~2.0"
}
}
Requirements
- SilverStripe 4 or 5
- you will need the Imagick extension.
For SilverStripe 3 use v1.
Usage
In your template just call $Pdf.getPdfPreviewImage where $Pdf is your File Object, containing a pdf file.
You then have a normal Image object, on which you can apply all methods you usually can apply on an image in SilverStripe.
F.e.: $Pdf.getPdfPreviewImage.Fill(60,60)
If you call this method on a non-pdf file, null will be returned.
Config
You can override all Params in your config.yml.
Ivoba\SilverStripe\SimplePdfPreview\SimplePdfPreviewImageExtension: dependencies: generator: %$Ivoba\SilverStripe\SimplePdfPreview\SimplePdfPreviewImagickGenerator folderToSave: "assets/someOtherFolder/" imagePrefix: "pdf-foobar" Injector: Ivoba\SilverStripe\SimplePdfPreview\SimplePdfPreviewImagickGenerator: class: Ivoba\SilverStripe\SimplePdfPreview\SimplePdfPreviewExecGenerator
You can create your own Generator class, simply implement SimplePdfPreviewGeneratorInterface.
This could be the case, when we you dont want to use Imagick but ImageMagick directly via exec.
Tests
To run tests for bundle standalone:
start the docker container:
docker-compose run php bash
inside the container run:
SS_DATABASE_NAME=ss SS_DATABASE_PASSWORD=ss SS_DATABASE_SERVER=db SS_DATABASE_USERNAME=ss vendor/bin/phpunit
Disclaimer
This extension is "simple" because it will just create a loose Image object. Mapping happens over the filename. So its rather risky, but sufficient for most cases.
Somebody please make a better PDF extension, with a PDF File type, a PDF FileField and a preview image generation after upload. :)
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-01