CakePHP中的ceeram / CakePdf插件实现

时间:2014-09-06 12:35:56

标签: php cakephp pdf cakephp-2.0 tcpdf

我已按照https://github.com/ceeram/CakePdf的所有步骤进行操作 和CakePHP 2 : Implement CakePDF plugin by Ceeram 但是插件不起作用意味着没有PDF生成。

自举

/ CakePdf插件设置 /

CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
Configure::write('CakePdf', array(
        'engine' => 'CakePdf.Tcpdf',
        'options' => array(
            'print-media-type' => false,
            'outline' => true,
            'dpi' => 96
        ),
        'margin' => array(
            'bottom' => 15,
            'left' => 50,
            'right' => 30,
            'top' => 45
        ),
        'orientation' => 'landscape',
        'download' => true
    ));

控制器

<?php
App::uses('AppController', 'Controller');
App::uses('CakePdf', 'CakePdf.Pdf');

    class InvoicesController extends AppController {
        public $components = array("RequestHandler");
        public function view($id = null) {
        $this->pdfConfig = array(
            'orientation' => 'portrait',
            'filename' => 'Invoice_' . $id
            );
        }
    }
?>

在app / View / Invoices / pdf / view.ctp中创建了view.ctp。

当我访问http://localhost/ckp_sports/invoices/view/1.pdf

错误:

Missing View

Error: The view for InvoicesController::view() was not found.

Error: Confirm you have created the file: D:\wamp\www\ckp_sports\app\View\Invoices\view.ctp

Notice: If you want to customize this error message, create app\View\Errors\missing_view.ctp

enter image description here

0 个答案:

没有答案