thujohn / pdf-l4

Dompdf for Laravel 4
MIT License
228 stars 72 forks source link

Multiple Headers and Protocol Error? #81

Open inctor opened 9 years ago

inctor commented 9 years ago

Hey Jonathan or anyone else who may know this,

In my development environment i'm getting this error, both on download and with show-method.

file_put_contents(/home/vagrant/*DOMAIN*/vendor/thujohn/pdf/src/Thujohn/Pdf/dompdf/lib/fonts/Times-Bold.afm.php): failed to open stream: Protocol error

I've tried to reinstall the entire package, added the fonts to /fonts in public folder but nothing works, still the same error, as a last resort, i've even tried to chmod 0777 the entire vendor-directory to see if it helped, it didn't.

However, on my production server, which both are nearly the same with a few exceptions, i'm getting this error instead. ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION

The code is as follows:

    $settlement = $this->repository->find($id);
    $view = View::make('settlements.show', compact('settlement'));
    return PDF::load($view->render(), 'A4', 'portrait')->show(sprintf('Invoice %s %d', Config::get('app.settlement_prefix'), $settlement->id));

Does anyone have any idea how to solve this? It happens both with show and with download.

olifolkerd commented 9 years ago

Hi Inctor,

this was caused by malformed headers (curious IE just ignores them but the other browsers cick up a stink)

i solved this by removing the line:

'Content-Disposition' => 'attachment; filename="'.$filename.'"'

from the download function in the Pdf.php file, located in vendoer\thujohn\pdf\src\Thujohn\Pdf

I hope that helps.

Cheers

Oli

xpns commented 9 years ago

Thanks ofolkerd, i did what you said and it worked for me!!

auralon commented 9 years ago

Just encountered this issue on a production server (didn't flag up on a dev server with a slightly different configuration... urgh!).

Commenting that line fixed it. I presume there is some server configuration setting, one that enables a level of strictness which produces errors when headers are supplied in this manner.

Should this be edited/patched, or is this expected behaviour, and should the server be reconfigured?