cakephp与加载引擎
大家好,我目前正在使用cake 2.1,我正在尝试在浏览器中以pdf格式呈现页面,但是我认为我没有正确加载引擎。我相信这是因为我没有在cakephp与加载引擎,cakephp,pdf,routes,Cakephp,Pdf,Routes,大家好,我目前正在使用cake 2.1,我正在尝试在浏览器中以pdf格式呈现页面,但是我认为我没有正确加载引擎。我相信这是因为我没有在routes.php中加载任何内容 以下是routes.php Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); /** * ...and connect the rest of 'Pages' controller's ur
routes.php
中加载任何内容
以下是routes.php
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
Router::mapResources(array('Invoices'));
/**
* Load the CakePHP default routes. Remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
<?php CakePlugin::load('DebugKit');
CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
CakePlugin::loadAll();
下面是boostrap.php
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
Router::mapResources(array('Invoices'));
/**
* Load the CakePHP default routes. Remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
<?php CakePlugin::load('DebugKit');
CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
CakePlugin::loadAll();
我使用这种方法加载pdf-
我用的是这个引擎
我已经被困在这个问题上好几天了,因此非常感谢您的帮助。如果您使用WkHtmlToPdf,您需要下载该引擎,因为它不是默认引擎。 点击这里:app/plugin/cakepdf/Vendor。 您可以看到默认值:dompdf、mpdf和tcpdf 我使用DomPdf。 在bootstrap.php中,按如下方式加载引擎:
Configure::write('CakePdf', array(
'engine' => 'CakePdf.DomPdf',
'pageSize'=>'A4',
'orientation' => 'landscape',
));
并在控制器内部使用:
$this -> pdfConfig = array (
'orientation' => 'landscape',
'download' => true,
'filename' => 'Invoice_' . $id
);
您还可以查看:
祝你好运,我希望这会有所帮助