使用KnpSnappyBundle从树枝视图生成PDF

我尝试使用KnpsnappyBundle从树枝视图生成pdf,它开始加载,直到“超过360秒的最大执行时间”,问题是我可以在生成的temp文件夹中找到pdf文件,但是需要在浏览器中为用户下载。

           try {
             $html = $this->renderView('ordreexecute.html.twig',['demande' => $demande,'username'=>$username]);

            $filename = 'myFirstsnappypDF';

             return new Response(
                $this->knpsnappy->getOutputFromHtml($html),200,array(
                    'Content-Type' => 'application/pdf','Content-Disposition' => 'attachement; filename="' . $filename . '.pdf"'
                )
            );
            }
            catch(\Exception $e){
                error_log($e->getMessage());
            }
linwanping 回答:使用KnpSnappyBundle从树枝视图生成PDF

我找到了一个解决方案,毕竟,即使当我使用absolute_url加载所有CSS和JS时,它也无法正常工作,我检查了此问题https://github.com/KnpLabs/KnpSnappyBundle/issues/82并成功了!!

本文链接:https://www.f2er.com/3116875.html

大家都在问