I keep getting the occasional error:
Error: Failed loading page http:///home/livesmartbureau/var/cache/prod/snappy/knp_snappy58e64e79602c84.27350345.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError
It is trying to access its OWN cache file (which it wrote) as by pre-pending http://
My config.yml is as follows:
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
image:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
temporary_folder: "%kernel.cache_dir%/snappy"
Controller Code:
$content = $this->render('Trace/traceHistoryDetails.html.twig',array(
'history' => $_SESSION['trace_history'],
'view' => 'PDF'
))->getContent();
$pdfGenerator = $this->get('knp_snappy.pdf');
$pdfGenerator->getInternalGenerator()->setTimeout(120);
return new Response($pdfGenerator->getOutputFromHtml($content), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="search_history.pdf"'
));
I have tried the temporary folder with quotes, and without quotes. I have tried various different temporary folders. The "snappy" folder is being created in /home/livesmartbureau/var/cache/prod.
I have looked everywhere for a resolution to this, but I am unable to find one. This issue happens OCCASIONALLY "intermittently" and not all the time and there is no pattern that I can detect of when it works and when it doesn't (content size does not seem to matter, as it sometimes happens on 1 page PDF's and other times 10 page PDF's work fine for the same twig template, just more data).
答案 0 :(得分:0)
您可以尝试renderView
代替render
吗?所有文档都显示了我使用的内容:
$content = $this->renderView('Trace/traceHistoryDetails.html.twig',array(
'history' => $_SESSION['trace_history'],
'view' => 'PDF'
))->getContent();
我不确定它是否会有所作为,但请试一试。