你的问题在这里:
return sfView::NONE;
将其更改为:
return sfView::HEADERS_ONLY;
由于额外的评论编辑更新.
由于您尝试下载pdf,因此您无法正确解决问题.不要使用sendContent().请参阅下文(这是我编写的生产网站的片段,已经证明可以在所有主流浏览器中使用):
$file = '/path/to/file.pdf';
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setStatusCode(200);
$this->getResponse()->setContentType('application/pdf');
$this->getResponse()->setHttpHeader('Pragma','public'); //optional cache header
$this->getResponse()->setHttpHeader('Expires',0); //optional cache header
$this->getResponse()->setHttpHeader('Content-Disposition',"attachment; filename=myfile.pdf");
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding','binary');
$this->getResponse()->setHttpHeader('Content-Length',filesize($file));
return $this->renderText(file_get_contents($file));