-1

Is it possible to open a pdf file link in a new tab? I'm using window.open(url, '_blank') at the moment, however, this downloads the file to the computer rather than opening it in a new tab.

user2771150
  • 722
  • 4
  • 10
  • 33
  • 2
    Which browser are you using? There may not be plugins to read the `pdf` file in the browser. You need to have the broswer configured to read the `pdf` files inside it. There is nothing wrong with the jS part. – bluefog Jan 09 '15 at 07:46
  • Not sure that JQuery is required to do this. Here is one solution. http://stackoverflow.com/a/11894771/1111233 – Giwan Jan 09 '15 at 07:48
  • server could also be set to force downloads for pdf – charlietfl Jan 09 '15 at 08:02

1 Answers1

0

for opening in the tab as inline rather than download you have to set header from server as descripbed in http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html

Now how to set? It depends on your server side implementation. Give more details about your environment like you using .net, php, java and what code is used to server files.

example for php

<?php
header("Content-type:application/pdf");

// It will be called downloaded.pdf
header("Content-Disposition:inline;filename='downloaded.pdf'");

// The PDF source is in original.pdf
readfile("original.pdf");
?>
Dev
  • 6,628
  • 2
  • 25
  • 34