user2794692
user2794692

Reputation: 391

Show pdf in symfony2

I want to show a pdf, but I did this and I only gets to download the pdf: This is my code:

        $response = new BinaryFileResponse($path);
        $response->trustXSendfileTypeHeader();
        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $file . '.pdf');
        return $response;

Any idea?

Upvotes: 1

Views: 1680

Answers (1)

Jovan Perovic
Jovan Perovic

Reputation: 20191

Have you tried setting Content-Type header?

$response->headers->set('Content-Type', 'application/pdf');

Also, ditch that setContentDisposition call since DISPOSITION_ATTACHMENT value forces your browser to download the file.

Upvotes: 5

Related Questions