tags:

views:

104

answers:

1

Is there a library or good documentation somewhere on the best way to reliably deliver documents in a users browser regardless of OS and browser. I'm mainly looking at PDF, office (2003 & 2007) and scanned images (.tiff) It seems that you always have to set different headers depending on the browser and the type of document being delivered. Right now:
header("Content-Type: $type"); header("Content-Disposition: inline; filename=$name"); header("Accept-Ranges: bytes"); header("Content-Length: $size"); header("Expires: 0"); header("Cache-Control: private");

Seems to work most often for IE but not always for FF. Any help/direction would be great

A: 

I think the code you have is probably about what it's gonna take. The problem is that for every browser you're going to need a variant on that code, so you're going to end up with a fairly complicated browser detection library with a bunch of special cases in it.

If inlining is really important to you I'd consider ripping them to a more web friendly format on the server and just serving that. You can always leave a "download" link at the bottom for the source file. Imagemagick can convert most formats to .png/.gifs, and you could use something like pdftohtml to rip the PDF's. There are some libraries that will do this for word documents, too, although the ones google spit out at me immediately were non-free.

easel