-
Notifications
You must be signed in to change notification settings - Fork 4
/
mPDF.php
72 lines (56 loc) · 1.43 KB
/
mPDF.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
67
68
69
70
71
<?php
namespace PdfResponse;
/**
* PdfResponse
* -----------
* Wrapper of mPDF.
* Generate PDF from Nette Framework in one line.
*
* @author Jan Kuchař
* @copyright Copyright (c) 2010 Jan Kuchař (http://mujserver.net)
* @license LGPL
* @link http://addons.nettephp.com/cs/pdfresponse
*/
/**
* Extended version of mPDF
* - added support for JavaScript
* - shortcut for opening print dialog
*/
class mPDF extends \mPDF {
// <editor-fold defaultstate="collapsed" desc="JavaScript support - use $mpf->IncludeJS($yourScript)">
var $javascript = "";
var $n_js;
function IncludeJS($script) {
$this->javascript.=$script;
}
function _putjavascript() {
$this->_newobj();
$this->n_js = $this->n;
$this->_out('<<');
$this->_out('/Names [(EmbeddedJS) ' . ($this->n + 1) . ' 0 R]');
$this->_out('>>');
$this->_out('endobj');
$this->_newobj();
$this->_out('<<');
$this->_out('/S /JavaScript');
$this->_out('/JS ' . $this->_textstring($this->javascript));
$this->_out('>>');
$this->_out('endobj');
}
function _putresources() {
parent::_putresources();
if (!empty($this->javascript)) {
$this->_putjavascript();
}
}
function _putcatalog() {
parent::_putcatalog();
if (!empty($this->javascript)) {
$this->_out('/Names <</JavaScript ' . ($this->n_js) . ' 0 R>>');
}
}
// </editor-fold>
function OpenPrintDialog() {
$this->IncludeJS("print();");
}
}