-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathQPdfJs.php
66 lines (53 loc) · 1.36 KB
/
QPdfJs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Description of QPdfJs
* wrapper for pdf.js
* modified file from orgin
* _viewer.php = viewer.html
* yii_viewer.css = viewer.css
* yii_viewer.js = viewer.js
*
* @author Lucky Vic <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version 0.1
*/
class QPdfJs extends CWidget
{
public $url;
public $options=array(
'sideBarOpen'=>false,
// ltr = left to right, rtl=right to left
'direction'=>'ltr',
'buttons'=>array(
'sidebarToggle'=>true,
'viewFind'=>true,
'pageUp'=>true,
'pageDown'=>true,
'zoomIn'=>true,
'zoomOut'=>true,
'scaleSelect'=>true,
'presentationMode'=>true,
'print'=>false,
'openFile'=>false,
'download'=>false,
'viewBookmark'=>false,
)
);
public function init(){
// check valid direction, default to ltr;
if(!in_array($this->options['direction'],array('rtl','ltr')))
$this->options['direction']='ltr';
}
public function run()
{
// Publish extension assets
$basePath=Yii::getPathOfAlias('ext.pdfJs.assets');
$baseUrl=Yii::app()->getAssetManager()->publish($basePath);
$this->render('_viewer',array(
'baseUrl'=>$baseUrl,
'url'=>$this->url,
'options'=>$this->options,
));
}
}
?>