Q:

Symfony2 serve open pdf file

I need to serve pdf files through the controller, but I can't make them open in browser window.  When I send response with pdf file, it renders gibberish, or if I follow example at http://symfony.com/doc/current/components/http_foundation/introduction.html#serving-files it downloads the file, but I need to open it in view mode, how can I do that? 
Here's what I'v got so far:
return new Response(readfile('/file/path/file.pdf'), 200,
    array('Content-Type' => 'application/pdf')
);

Am I missing something, or maybe there's something wrong with my php or apache configuration? 

A:

Found a solution:
Add BinaryFileResponse before controller class declaration from example
use Symfony\Component\HttpFoundation\BinaryFileResponse;

In controller action return BinaryFileResponse
return new BinaryFileResponse('/file/path/file.pdf');

