pdf-l4 icon indicating copy to clipboard operation
pdf-l4 copied to clipboard

Multiple Headers and Protocol Error?

Open inctor opened this issue 10 years ago • 3 comments

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.

  • And yes, i've searched previous issues and google for a similar problem, but without much luck sadly.

inctor avatar Jan 23 '15 11:01 inctor

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

olifolkerd avatar Feb 07 '15 23:02 olifolkerd

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

xpns avatar Feb 09 '15 12:02 xpns

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?

auralon avatar Feb 18 '15 16:02 auralon