CakePHP 2.10.11
- CakePdf
- wkhtmltopdf
- BoostCake(bootstrap3)
な環境で、viewよりPDFの書き出しを行っています。
この度、PDFの書き出しをバッチ処理する必要が生じ、Console/Commandで試行錯誤しています。
結果、PDFの生成には成功したのですが、bootstrap3等のJavaScriptがまったく機能しません。
なんとかConsole/CommandでJavaScriptを効かす方法はないでしょうか。
追記:コードを追加しました。
app/Console/Command/MkpdfShell.php
lang
1App::uses('CakePdf', 'CakePdf.Pdf'); 2App::uses('HtmlHelper', 'View/Helper'); 3App::uses('BoostCakeHtmlHelper', 'View/Helper'); 4App::uses('Router', 'Core'); 5 6class MkpdfShell extends AppShell { 7 public function startup(){ 8 parent::startup(); 9 } 10 public function main() { 11 $CakePdf = new CakePdf(Configure::read('CakePdf')); 12 $this->Html = new BoostCakeHtmlHelper(new View()); 13 $this->Html->className = 'BoostCake.BoostCakeHtml'; 14 $this->User->recursive = 1; 15 $CakePdf->viewVars(['result' => $this->User->find('first', $options) ]); 16 $CakePdf->template('bsprint', 'bootstrap'); 17 $CakePdf->orientation('landscape'); 18 $pdf = $CakePdf->output(); 19 $pdf = $CakePdf->write(TMP."hoge.pdf"); 20 } 21}
app/View/User/pdf/bsprint.ctp
lang
1<table class="table table-condensed"> 2... 3<!--- ここにbootstrap3で装飾した表が入る ---> 4... 5</table>
app/View/Layout/pdf/bootstrap.ctp にて、bootstrap3等の読み込み
回答2件
あなたの回答
tips
プレビュー