22

Sometimes you want to follow a pdf/image/etc link and actually see it in the browser instead of downloading it.
In my most recent run-in it was with a screenshot on a Mantis server I'm using.

When I click to follow the link it immediately prompts me to save the file, with no option to open it the browser.
I really don't want to download it, open it in an image viewer, then remember to delete the file when I'm done. I'd like that to be handled by the browser when I close the tab for normal images/pdfs like when you click open [image] in new tab.

I know why the browser is doing it, the content is being served with the HTTP header Content-Disposition:attachment, but I'm sure that there would be an advanced setting, hidden context menu option, or awesome extension that would let you view something that somebody wanted you to actually save.

Does anyone know anything like that?


EDIT

Seems Firefox has an add-on for it, but I can't find a port for Chrome.

Hashbrown
  • 3,338
  • 4
  • 39
  • 51

4 Answers4

6

Who defines whether the file will be downloaded or opened is the site developer. Naturally the file is opened in the browser, but if the developer force the HTML header below, will always be downloaded.

There is no way to force. :(

Response.AddHeader("Content-Disposition", "attachment; filename=fileToForceDownload.pdf");
Response.AddHeader("Content-Length", 12345);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytesOfFile);

To open in browser, developer must declare:

Response.AddHeader("Content-Disposition", "inline; filename=fileToOpen.pdf");
Response.ContentType = "application/pdf";

The above was written in C# but its parameters are common to any language sites

0

as said by Sergio it is the site developer who defines either the file will get downloaded or opened in browser. If you want to view pdf documents then I suggest to enable the Google Docs Extension which comes with chrome by default. Press the ctrl button while you click the image, it opens the image in new tab. I hope this works for users having this issue.

Grayson
  • 23
0

There's Modify Content-Type. It's working as I expected (PNGs open in the internal viewer despite Content-Disposition: attachment in the response headers) with a rule of:

URL Filter:       .*
Original Type:    application/png
Replacement Type: application/png
Disposition:      inline

Note well that this may expose you to cross-site scripting vulnerabilities, and you would be wise not to allow .* in the URL filter. Add to it only as needed.

Original answer

across
  • 101
-1

Have you tried searching Google for "open PDF in Chrome"?

I had an extension that worked well:

Kami (formerly Notable PDF)
2.0.6344
Document Viewer and Office Tool for your browser

However, I disabled it because PDF will open in Chrome, even without that extension.

I do have:

Office Editing for Docs, Sheets & Slides
109.1486.1491
View and edit Microsoft Word, Excel, and PowerPoint files...

This allows me to open most Office files without having Office (look ma, no Office).

Hope this helps.