admin管理员组

文章数量:1355589

I have a web service which will return pdf stream for a given document id and I will set the content type to application/pdf and write the out put to IFRAME upto this point I am done and OK! My problem is : My requirement is to disable the pdf download toolbar button in IFRAME, is there any way using JavaScript or j query to disable the PDF toolbar buttons, i tried some thing like this:

<iframe src="view/1.pdf?page=hsn#toolbar=0" width="875" height="95%" id="iframe11">
     <p>Your browser does not support iframes.</p>
     </iframe>

I tried setting toolbar=0 for iframe tag but it dint work. an anyone please tell me how to achieve this ?

I have a web service which will return pdf stream for a given document id and I will set the content type to application/pdf and write the out put to IFRAME upto this point I am done and OK! My problem is : My requirement is to disable the pdf download toolbar button in IFRAME, is there any way using JavaScript or j query to disable the PDF toolbar buttons, i tried some thing like this:

<iframe src="view/1.pdf?page=hsn#toolbar=0" width="875" height="95%" id="iframe11">
     <p>Your browser does not support iframes.</p>
     </iframe>

I tried setting toolbar=0 for iframe tag but it dint work. an anyone please tell me how to achieve this ?

Share Improve this question asked Dec 2, 2013 at 12:51 abhiabhi 8205 gold badges17 silver badges29 bronze badges 3
  • 2 The toolbar you're referring to is most likely a built-in or external plugin used by the browser for displaying PDF files. You cannot disable it, as it's not part of the iframe. – Boaz Commented Dec 2, 2013 at 12:56
  • 2 You can't control that, since it's a browser feature. You should go for something like googlesystem.blogspot..br/2009/09/… – rafaelcastrocouto Commented Dec 2, 2013 at 13:00
  • hey did you solved your problem need help with that? – JAVA_RMI Commented Feb 9, 2017 at 9:01
Add a ment  | 

3 Answers 3

Reset to default 2

I hope I am not very late to reply. But here's is something you can do to prevent the users. Use iFrame to display your PDF and make sure that you are displaying using Google. I used the following code :

 <iframe src="http://docs.google./gview?url=http://www.tutorialspoint./php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
</iframe>

Here you can simply change the url=http://www.tutorialspoint./php/php_tutorial.pdf and replace it by your own URL where you kept your PDF.

Use embed tag instead iframe tag:

<embed src="http://localhost/yourpdf.pdf#toolbar=0" style="width:600px; height:500px;">

Only download and print button cannot be hidde. Either you can hide whole toolbar ( using #toolbar=0) or keep all. Here is what i did to only these buttons:

<div class="position-relative" style="height: 95%">
    <embed src="assets/your-pdf.pdf" width="100%" height="100%"></embed>
    <div class="testttt"></div>
</div>

and here is styling:

.testttt{
    height: 40px;
    width: 200px;
    background-color: #323639;
    position: absolute;
    right: 0;
    top: 10px;
    z-index: 9999999999999999999999;
}

Boom you got download and print button hidden.

本文标签: javascriptHow to disable pdf toolbar download button in iframeStack Overflow