Not able to display pdf in browser without toolbar - javascript

I am using this code to display pdf in browser
<embed src="D:\Books\Git\Scott.pdf#toolbar=0&scrollbar=0&statusbar=0&navpanes=0" width="500" height="500">
I want only simple pdf in browser to display without giving any option like download, print to the user. This code is not working for me. Please help

Related

embed and iframe doesnt view a pdf file

Im trying to view a pdf file using html. But whenever i try to open it, the browser download the file instead of viewing it.. I dont know whats wrong. I tried embed and iframe and both results the same thing. It downloads the file.
Thing is when i see other websites, it works. so i know for sure its not because extension problems. checked the pdf viewer extension and its on.
Here is my code. how is this happening??
<div class="row">
<div class="col-sm">
<p><span class="fw-bold">DOKUMEN : </span></p>
<iframe src="http://127.0.0.1:8000/docs/testpdf.pdf" width="100%" height="100%" style="border: none;"></iframe>
<embed src="http://127.0.0.1:8000/docs/testpdf.pdf" type="application/pdf" width="100%" height="600px" />
</div>
</div>
Some browsers like IE dosent have the proper plug-in to render embedded PDF. You better work with browsers like firefox or chrome. Here is a page that answered your question before.
downloading PDF embedded file instead of viewing it

HTML pdf not showing in safari

i have a php page which shows a list of invoices. clicking on any of those invoices shows its pdf file. When the user clicks on any invoice, the src of the embed tag is changed by jQuery to the appropriate pdf file.
Works very well, but strangely enough it behaves differently in safari then in firefox for instance.
In firefox i can just click on an invoice -> the pdf shows. if i right after that click on another invoice and after that click on the first invoice again -> the pdf shows again.
Safari: If i re-click an invoice, i get a blank pdf (embed tag). And downloading of that pdf results in a 0kb file.
Seems to only happen in safari.
Has anyone encountered this before and maybe know a solution to this issue?
i have googled and tried a lot but it's still not working.
Html:
<div class="card-body">
<embed id="invoice_scan" src="" type="application/pdf" width="100%" height="400px" />
</div>
jQuery:
$('#invoice_scan').attr('src', '/docs/pdf_file1.pdf );
I had this issue showing a pdf in an object tag using angular.
The fix was to remove type="application/pdf" from the object tag.
I have a similar issue with Safari 15.5 with <object> tag. As soon as PDF gets loaded, it was crashing the browser. I removed type="application\pdf" conditionally for safari. That seems to be working.
Alternate option would be use iFrame for PDF's.
Why is this code failing on MacOS Big Sur Safari?

How to stop downloading PDF in an iframe automatically and instead view the file?

I have an iframe on my website that loads a PDF file :
<iframe src="file.pdf" frameborder="0" width="800" height="600"></iframe>
But it's downloaded automatically , I want to view the file not to download it .
So how could I fix this problem?
Try using embed
<embed src="file_url" height="" width="">
You need to tell your server to send that file as application/pdf ("PDF")
...
Bonus titbits:
- why do you have a PDF on a website? The web page you're displaying your PDF from already displays things PDF files display
- why are you loading a PDF in an iframe/etc. if you just want it to be downloaded? Why not just link to it

PDF viewer toolbar is disabled in MS Edge

I am using jquery plugin for opening modal pop-ups. The pop-up can open the pdf document. I am using tag object for displaying pdf like this:
<object id="idPdf" width="300" height="400" type="application/pdf"
data="MY_PDF_URL">
<span>PDF plugin is not available.</span>
</object>
It works fine in all browsers, but the pdf toolbar is missing in MS Edge (user can not save or print). It works fine in new window or tab, but in pop-up has the issue. Anyone know how to fix it?

How to disable pdf toolbar download button in iframe

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 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.
Use embed tag instead iframe tag:
<embed src="http://localhost/yourpdf.pdf#toolbar=0" style="width:600px; height:500px;">

Categories

Resources