質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,3 +17,75 @@
|
|
17
17
|
結果、PDFの生成には成功したのですが、bootstrap3等のJavaScriptがまったく機能しません。
|
18
18
|
|
19
19
|
なんとかConsole/CommandでJavaScriptを効かす方法はないでしょうか。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
追記:コードを追加しました。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
**app/Console/Command/MkpdfShell.php**
|
28
|
+
|
29
|
+
```lang-php
|
30
|
+
|
31
|
+
App::uses('CakePdf', 'CakePdf.Pdf');
|
32
|
+
|
33
|
+
App::uses('HtmlHelper', 'View/Helper');
|
34
|
+
|
35
|
+
App::uses('BoostCakeHtmlHelper', 'View/Helper');
|
36
|
+
|
37
|
+
App::uses('Router', 'Core');
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
class MkpdfShell extends AppShell {
|
42
|
+
|
43
|
+
public function startup(){
|
44
|
+
|
45
|
+
parent::startup();
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
public function main() {
|
50
|
+
|
51
|
+
$CakePdf = new CakePdf(Configure::read('CakePdf'));
|
52
|
+
|
53
|
+
$this->Html = new BoostCakeHtmlHelper(new View());
|
54
|
+
|
55
|
+
$this->Html->className = 'BoostCake.BoostCakeHtml';
|
56
|
+
|
57
|
+
$this->User->recursive = 1;
|
58
|
+
|
59
|
+
$CakePdf->viewVars(['result' => $this->User->find('first', $options) ]);
|
60
|
+
|
61
|
+
$CakePdf->template('bsprint', 'bootstrap');
|
62
|
+
|
63
|
+
$CakePdf->orientation('landscape');
|
64
|
+
|
65
|
+
$pdf = $CakePdf->output();
|
66
|
+
|
67
|
+
$pdf = $CakePdf->write(TMP."hoge.pdf");
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
**app/View/User/pdf/bsprint.ctp**
|
76
|
+
|
77
|
+
```lang-php
|
78
|
+
|
79
|
+
<table class="table table-condensed">
|
80
|
+
|
81
|
+
...
|
82
|
+
|
83
|
+
<!--- ここにbootstrap3で装飾した表が入る --->
|
84
|
+
|
85
|
+
...
|
86
|
+
|
87
|
+
</table>
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
**app/View/Layout/pdf/bootstrap.ctp** にて、bootstrap3等の読み込み
|