使用vsmoraes/laravel-pdf创建多个pdf


Multiple pdf creation using vsmoraes/laravel-pdf

我使用vsmoraes/laravel-pdf创建pdf。对于单个pdf创建,它工作得很好。但是当我试图创建多个pdf时,它显示了错误没有找到块级父级。不好。这就是我在控制器代码中生成pdf所做的。需要帮助,谢谢。

<?php
namespace App'Http'Controllers;
use Vsmoraes'Pdf'Pdf;
class HomeController extends BaseControler
{
    private $pdf;
    public function __construct(Pdf $pdf)
    {
        $this->pdf = $pdf;
    }
public function helloWorld()
{
    $html = view('pdfs.example1')->render();
    for ($i = 0; $i < 3; $i++) {
        $this->pdf->load($html, 'A3')->filename(public_path() . $i)->output();
    }
}
}
public function helloWorld()
{
    $html = view('pdfs.example1')->render();
    for ($i = 0; $i < 3; $i++) {
        return $this->pdf->load($html)->show();
    }
}

for总是在第一个循环时从helloWorld()退出。你确定你想要这样吗?