Skip to content
Yii2 PDFJS bundle of PDF.js plugin
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Fixed watermark to false when WATERMARK_TEXT = '' Jul 22, 2016
controllers add watermark text support Jul 21, 2016
docs update readme Jul 21, 2016
views add watermark text support Jul 21, 2016
CHANGELOG.md update changlog Jul 21, 2016
Module.php add watermark text support Jul 21, 2016
PdfJs.php Fixed watermark to false when WATERMARK_TEXT = '' Jul 22, 2016
PdfJsAsset.php chang namespace Jul 17, 2016
README.md update readme Jul 21, 2016
composer.json update composer Jul 17, 2016

README.md

Yii2 PDFJS

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

Yii2 PDFJS bundle of PDF.js plugin. PDF.js Portable Document Format (PDF) viewer.

Installation

The preferred way to install this extension is through composer.

Either run

php composer require --prefer-dist yii2assets/yii2-pdfjs ">=1.0"

or add

"yii2assets/yii2-pdfjs": ">=1.0"

to the require section of your composer.json file.

Module Setup

The extension has been created as a module to enable access preview pdf file. you must add the module to your configuration file.

//....

'modules'=>[
  'pdfjs' => [
       'class' => '\yii2assets\pdfjs\Module',
   ],
],

//...

Usage

Once the extension is installed, simply use it in your code by :

<?php
use yii\helpers\Url;
?>

<?= \yii2assets\pdfjs\PdfJs::widget([
  'url'=> Url::base().'/downloads/manualStart_up.pdf'
]); ?>

Using a yii2-pdfjs widget inside a modal dialog.

<?php
use yii\bootstrap\Modal;
use yii\helpers\Url;

Modal::begin([
    'header' => '<h2>Hello world</h2>',
    'toggleButton' => ['label' => 'click me'],
]);

echo \yii2assets\pdfjs\PdfJs::widget([
  'url' => Url::base().'/downloads/manualStart_up.pdf'
]);

Modal::end();
?>

Using a yii2-pdfjs widget fullscreen viewer

http://app-url/index.php?r=pdfjs&file=download/manualStart_up.pdf

Config Width & Height

<?php
use yii\helpers\Url;
?>

<?= \yii2assets\pdfjs\PdfJs::widget([
  'width'=>'100%',
  'heith'=> '500px',
  'url'=> Url::base().'/downloads/pdfjs.pdf'
]);
?>

Config disable toolbar buttons

<?php
use yii\helpers\Url;
?>

<?= \yii2assets\pdfjs\PdfJs::widget([
  'url'=> Url::base().'/downloads/pdfjs.pdf',
  'buttons'=>[
    'presentationMode' => false,
    'openFile' => false,
    'print' => true,
    'download' => true,
    'viewBookmark' => false,
    'secondaryToolbarToggle' => false
  ]
]);
?>

Add Watermark text

//....

'modules'=>[
  'pdfjs' => [
       'class' => '\yii2assets\pdfjs\Module',
       'waterMark'=>[
         'text'=>' Yii2 PDF.JS',
         'color'=> 'red',
         'alpha'=>'0.3'
       ]
   ],
],

//...

You can’t perform that action at this time.