我需要通过控制器提供PDF文件,但我无法使其在浏览器窗口中打开。当我发送包含PDF文件的响应时,它呈现为乱码,或者如果我按照http://symfony.com/doc/current/components/http_foundation/introduction.html#serving-files的示例下载该文件,但我需要以视图模式打开它。我该怎么做?
这是我目前的代码:
return new Response(readfile('/file/path/file.pdf'), 200,
array('Content-Type' => 'application/pdf')
);
我是否遗漏了什么,或者可能是我的php或apache配置有问题?