php - 使用 cakephp 3 和 doompdf 创建 pdf,未生成 pdf
问题描述
我正在尝试使用 cakephp3 和 doompdf 创建 PDF 报告,但没有生成 pdf,只是生成了 html。
bootstrap.php
:
Plugin::load('Dompdf');
routes.php
:
Router::scope('/', function ($routes) {
$routes->extensions(['pdf']);
});
'控制器:'
public function pdf() {
$this->viewBuilder()
->className('Dompdf.Pdf')
->layout('Dompdf.default')
->options(['config' => [
'filename' => 'voluntariopdf',
'render' => 'download',
]]);
}
'看法:'
<?php $this->start('header'); ?>
<p>Header.</p>
<?php $this->end(); ?>
<?php $this->start('footer'); ?>
<p>Footer.</p>
<?php $this->end(); ?>
<h1>Teste</h1>
<p>Teste</p>
<p>teste</p>
HTML 正在按预期生成,但 pdf 不是。谁能解释一下为什么?
解决方案
尝试这样做:
$this->viewBuilder()
->className('Dompdf.Pdf')
->layout('Dompdf.default')
->options(['config' => [
'upload_filename' => WWW_ROOT.'pdf/mydocument.pdf',
'render' => 'upload',
]]);
安装后,有没有生成符号链接?
// In a shell
bin/cake plugin assets symlink
推荐阅读
- java - 如何将枚举值与类关联?
- elasticsearch - 迁移后未加载索引
- reactjs - 使用 Formik 影响 Yup 中的每个字符串测试的正确方法是什么
- javascript - 在 Flask 中操作和显示用户上传的图像
- scala - 查找是否存在 Seq 的 n 个元素的总和,等于一个值
- python - 用于从模板创建新 GitHub 存储库的 Bash 脚本
- ios - AWS SNS 是否将 apns-push-type 和 apns-priority 添加到其 iOS 推送通知标头?
- node.js - nodejs项目无法通过谷歌计算引擎上托管的应用程序将图像上传到谷歌云存储,本地设置能够上传文件
- python - /post/how-to-write-a-pattern-to-accept-this-kind_of_url(在 Django 中)
- excel - 写入txt文件后Excel vba退出子