我已在app / plugins文件夹中安装了CakePdf插件,并按照所有可能的文档进行操作,因此我的设置如下:
// config/bootstrap.php
Plugin::load('CakePdf', ['bootstrap' => true, 'routes' => true]);
Configure::write('CakePdf', [
'engine' => 'CakePdf.WkHtmlToPdf',
'binary' => '/wkhtmltopdf/bin/wkhtmltopdf',
'margin' => [
'bottom' => 15,
'left' => 50,
'right' => 30,
'top' => 45
],
'orientation' => 'landscape',
'download' => true
]);
// config/routes.php
Router::extensions(['pdf']);
// controller/AppController.php
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authenticate' => ['Form' => ['fields' => ['username' => 'email', 'password' => 'password']]],
'loginAction' => ['controller' => 'Users', 'action' => 'login'],
'loginRedirect' => ['controller' => 'Users', 'action' => 'index'],
'logoutRedirect' => ['controller' => 'Users', 'action' => 'login'],
'authorize' => 'Controller'
]);
}
以下是示例agendaPdf
操作的示例:
function agendaPdf(){
$agenda = 'sample agenda';
$this->viewBuilder()->options([
'pdfConfig' => [
'orientation' => 'portrait',
'filename' => 'agenda_123'
]
]);
$this->set('agenda', $agenda);
}
我已经完成了PDF布局,以及模板文件夹中用于模型操作的PDF文件夹,但是,如果我转到app/users/agendapdf.pdf
,我会收到以下消息:
在UsersController中未定义动作agendapdf.pdf 错误:在文件中创建UsersController :: agendapdf.pdf():src / Controller / UsersController.php。
我真的很想知道可能出现什么问题以及如何解决这个问题。
答案 0 :(得分:0)
CakePdf不包含任何受支持的PDF引擎,因此我尝试了wkhtmltopdf(Refered Link)。
逐步过程:
this.modiyForm=new FormGroup({
dateDeb:new FormControl(),
dateFin:new FormControl(),
workTypeControl:new FormControl(),
description:new FormControl(),
Remarque:new FormControl(),
checkboxGroupOperatingRange:new FormGroup({
operatingRanges:new FormArray([])
})
checkboxGroupAgentInShiftAndDispoAndIntervenant:new FormGroup({
shiftControl:new FormControl()
agentsInShiftSelected:new FormArray([]),
agentsDispo:new FormArray([]),
agentParticipantsControl:new FormControl(),
externalActorControl:new FormControl(),
externalActorParticipantsControl:new FormControl(),
}),
equipmentLocationForm:new FormGroup({
equipmentLocationStructureControl:new FormControl()
equipmentLocationPlaceControl:new FormControl()
...
})
})