Tuesday, July 22, 2008

Inline PDF for Mac Firefox 3

One of my last annoyances with Firefox on the Mac was that it didn't display PDF's "inline" - in the browser window. Instead, you had to download and open it in another program.

It wasn't just Firefox either, originally Safari had issues with this as well.

It always seemed odd to me because OS X is otherwise very PDF "friendly".

It bugged me again today so I searched to see if there was a solution yet and I found the firefox-mac-pdf plugin.

Of course, the first time I tried it I got a blank screen :-( but the next one I tried worked. The one that wouldn't work is landscape - maybe that's the problem, although I couldn't see any known problems with landscape.

Strangely, Gmail still forces you to download PDF's to view them. (I think by setting the Content-Disposition header.) I'm not sure why they do this. Maybe because otherwise people can't figure out how to download because they don't think to right-click and save. You could always have separate download and view links, but that only makes sense if you know the browser can handle viewing, which is probably difficult to determine.

Still, it's nice to finally have this.

1 comment:

Unknown said...

"(I think by setting the Content-Disposition header.) "

True but, you need to make sure you set it as inline.

For all PHP freaks out there it goes like this:

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Thu, 1 Jan 2009 05:00:00 GMT');
header('Cache-Control: private');
header('Content-type: application/pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$someSize);
header('Content-Disposition: inline; filename="mypdf.pdf"');