Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide toolbar coming with pdf file when trying to render by using iframe in firefox?

Tags:

javascript

php

I want to remove toolbar coming with PDF while rendering through iframe. It is working fine in browsers such as Chrome, IE when I use #toolbar=0 with the URL (or file path). But it is not working in Firefox.

Can anyone suggest where am I doing wrong ?

This is my code.

<html>
<body>
  <iframe src="Reports/reports.pdf#toolbar=0" width="100%;" height="80%">                        
</iframe>
</html>
like image 582
SwR Avatar asked Apr 19 '16 09:04

SwR


1 Answers

I think it's also dependent on the application/plugin in which browser opens PDF, it works differently and it might ignore there directives (depending on browser, plugin, platform, PDF viewer).

The general recommendation here is to use these "directives" at the end of URL:

#toolbar=0&navpanes=0

You may also try recommendations from http://blogs.adobe.com/pdfdevjunkie/web_designers_guide :

Embedding using PDFObject

You could use basic HTML markup to embed PDF files in your page but there is a more elegant solution out there. Take a look at PDFObject by Philip Hutchison. PDFObject is a pretty easy scripting tool for dynamically embedding PDF files into web pages. It uses JavaScript to inject an element into the DOM tree of your HTML file. There’s even a handy code generator to help you out with all of the extra parameters you may need.

<script type="text/javascript" src="scripts/pdfobject.js"></script>
<div id="pdf1" style="width:500px; height:375px;"></div>
<script type='text/javascript'>
var myPDF = new PDFObject({ 
     url: 'ConferenceGuide.pdf', 
     pdfOpenParams: { 
          view: 'Fit', 
          scrollbars: '0', 
          toolbar: '0', 
          statusbar: '0', 
          navpanes: '0' }
      }).embed('pdf1'); 
</script>

The link to PDFObject is here: http://www.pdfobject.com/ (taken from their website)


SMALL UPDATE

Disclaimer: To avoid further speculations on the topic, you need to take into consideration that your clients/customers might have different plugins and PDF viewers installed on their machines, and different versioning of applications and plugins, so none of the above solutions will work in 100% of the cases. Adobe for example, has separate plugin for Firefox installed, and they had different versions and different behavior built in.

here's reference for the tricky case with FF and Reader X, as the good example of the above said.

like image 147
Farside Avatar answered Sep 19 '22 13:09

Farside