Previewer PDF File with PDF.js for Yii2
Yii2 PDF.js uses PDF.js
Demo: https://mozilla.github.io/pdf.js/web/viewer.html
Package is available on Packagist, you can install it using Composer.
composer require diecoding/yii2-pdfjs '^1.0'
or add to the require section of your composer.json
file.
'diecoding/yii2-pdfjs': '^1.0'
- PHP 7.2+
- yiisoft/yii2
...
'modules'=>[
'pdfjs' => [
'class' => \diecoding\pdfjs\Module::class,
],
],
...
echo \diecoding\pdfjs\PdfJs::widget([
'url' => '@web/uploads/dummy.pdf',
]);
echo Url::to(["/pdfjs", 'file' => Url::to('@web/uploads/dummy.pdf', true)], true);
echo \diecoding\pdfjs\PdfJs::widget([
'url' => '@web/uploads/dummy.pdf',
'options' => [
'style' => [
'width' => '100%',
'height' => '500px',
],
],
]);
echo \diecoding\pdfjs\PdfJs::widget([
'url' => '@web/uploads/dummy.pdf',
'sections' => [
'toolbarContainer' => false,
],
]);