使用 CakePdf 将 Html 的块转换为没有视图文件的 Pdf

Using CakePdf to turn a block of Html into a Pdf without a View file

使用 CakePHP 2.6.7

我已经安装了CakePdf plugin. I was hoping to be able to pass it the full html of a page and have it generate the corresponding pdf (in the same way wkhtmltopdf)。但是当使用下面的代码将pdf作为字符串获取时

$cakePdf = new CakePdf();
$cakePdf->template();   // tried missing this out and specifying null for both parameters as well
$cakePdf->html($html); // $html is the full content of the page

我收到 app\View\Pdf\.ctp 的视图异常异常。

如何让 CakePdf 不需要视图文件?

附加错误

我同时也出现以下错误

Notice (8): Uninitialized string offset: 0 [CORE\Cake\View\View.php, line 1001]

对于试图从 html 的给定片段而不是使用视图生成 pdf 的任何其他人 - 解决方案是以下代码

$cakePdf = new CakePdf(Configure::read('CakePdf'));
$pdf_string = $cakePdf->output($html);

其中所有配置选项已存储在 ConfigureCakePdf 变量中,与文档保持一致。