**Controller** : Test
**View where the form resides** : index.ctp
**View containing fpdf code** : pdf.ctp
我使用 FPDF 生成一个 pdf 文件,但 pdf 文件无法正确呈现。我已经确认 FPDF 代码没有错误。
在网址上
localhost/project/test
我将填写表格并按提交。这将提交给
localhost/project/test/pdf
但是在这里,pdf 无法正确呈现。它只是继续告诉加载。
如果我将其提交到其他文件夹/pdf.php文件(php文件中的fpdf代码相同(一切都还好
localhost/fpdf/pdf.php
我自己回答我的问题。来吧,人们帮助我!!
问题是输出没有呈现为 pdf。我使用这个控制器来解决我的问题。
public function pdf()
{
$this->response->type('pdf');
}