0

I have tried to achieve by using google docs viewer like below in html template.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>View Document</title>
</head>
<body style="margin: 0px; padding: 0px; overflow: hidden">
   <form id="form1" runat="server">
       <div>
           <iframe runat="server" id="iframe" src="https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/augmenting.pdf&embedded=true" style="height: 100%; width: 100%; position: absolute;" frameborder="0"></iframe>
       </div>
   </form>
</body>
</html>

It is opening document in new window but download option is exists like below screenshot.

enter image description here

can any one suggest me to remove pop out button in google docs viewer or please suggest me to any other way to open any type (PDF,excel,doc etc.) of file without download option using Asp.net c#.

Any answer appreciated

Thanks in Advance......!

Balaraju Polaki
  • 133
  • 1
  • 15
  • 2
    ...and what stops me from taking the documents URI from the page source and download it anyway? – Christoph Fink Feb 08 '18 at 14:37
  • It seems that you are using WebForms, then how about to transmit file with Content-Type? this can help you : https://stackoverflow.com/questions/27974374/returning-a-downloadable-file-using-a-stream-in-asp-net-web-forms – Kangjun Heo Feb 08 '18 at 14:46
  • @ChrFin : I didn't get you.Thanks – Balaraju Polaki Feb 08 '18 at 14:54
  • @Kang-Jun Heo : I need to view document without download option. as per your reply it seems it will download the file.Thanks. – Balaraju Polaki Feb 08 '18 at 14:57
  • 1
    What I was getting at is, that if your goal ist, that the user shouldn't be able to download the file, simply removing the "download button" won't get you there, as there are several other ways to download the file... – Christoph Fink Feb 08 '18 at 14:59
  • @ ChrFin :actually i don't want to download a document.i just want to view the document.for that i have tried google docs viewer but it won't works.any other option please suggest me.Thanks. – Balaraju Polaki Feb 08 '18 at 15:01

1 Answers1

0

As far as i know, when you request to open a document on internet they are stored locally on clients machine either in temp file or some browser specific directory in order to display it. Browser can only display local files once they are downloaded. So any user with some technical knowledge have a way to retrieve that file.

1)Few ideas are to open that file in a new page inside a iframe and disable the right click. That might help you user download the file.

2)Also try to set read only permission on the files that way user will not be able to edit/copy the content of the file if that's what you are going to achieve.

3)Also user can print the page which will give them the content of the file, its not like download but i am not sure what restrictions you want to enforce on user.

Arpan
  • 92
  • 9