Reputation: 818
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 ?
Upvotes: 0
Views: 30790
Reputation: 19
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.
Upvotes: -1
Reputation: 67
Use embed tag instead iframe tag:
<embed src="http://localhost/yourpdf.pdf#toolbar=0" style="width:600px; height:500px;">
Upvotes: 2
Reputation: 427
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.com/gview?url=http://www.tutorialspoint.com/php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
</iframe>
Here you can simply change the url=http://www.tutorialspoint.com/php/php_tutorial.pdf
and replace it by your own URL where you kept your PDF.
Upvotes: 2