65

Though I think the answer maybe in this other question's answer concerning the pdf specification, is it possible to not display the adobe acrobat toolbars in an embedded pdf document?

2

6 Answers 6

128

If you use any browser besides Firefox browser, then the following code will embed a PDF file without any toolbars:

<embed
  src="http://URL_TO_PDF.com/pdf.pdf#toolbar=0&navpanes=0&scrollbar=0"
  width="425" height="425" />
7
  • 6
    Correction: It does still work for me, but only if I use all these parameters: #toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0
    – plocks
    Nov 7, 2017 at 8:42
  • 2
    @leeand00 This is helpful for the developers whose client only use chrome. Also, this will work for non-techies. What about tech person? he/she will make #toolbar=1 in the URL and then download the pdf. Oct 11, 2019 at 14:09
  • 1
    It works for me with the caveat that when I refresh (using Chrome) the toolbar appears again. I am trying to figure out why. Does anyone know the cause?
    – Fom
    Apr 7, 2021 at 15:16
  • 1
    To add to the comment @plocks makes above. I could not get #navpanes=0 to work by itself, but I could omit &scrollbar=0 successfully in Chrome. #pagemode=none didn't work for me in Firefox, but the Firefox sidebar doesn't show by default so that was less of an issue for me.
    – mrwweb
    Jul 14, 2021 at 21:27
  • 1
    The list of parameters seems to have moved. I found more details here: pdfobject.com/pdf/pdf_open_parameters_acro8.pdf
    – StephenD
    Jun 6, 2023 at 17:09
18

You can use #toolbar to hide above toolbar.. if toolbar =0, it will disable it.. when toolbar=1, this will enable it.. hope so it will work. this works for me

<embed src="filename.pdf#toolbar=0" width="500" height="375"> (Disable toolbar)
<embed src="path/filename.pdf#toolbar=1" width="500" height="375"> (Enable toolbar
2
  • 5
    I am using this with a url like <embed [attr.src]="dataLocalUrl+'#toolbar=0'" width="100%" height="80%"/> . But still the toolbar is there. Do you have any idea about this? (I am using this in Angular)
    – SMash
    May 26, 2020 at 5:52
  • @SMash You can Do it like this this.pdfUrl= this.sanitizer.bypassSecurityTrustResourceUrl(dataLocalUrl+ '#zoom=70&toolbar=0'); and in your constructor public sanitizer: DomSanitizer Jun 9, 2021 at 8:54
10

There is no guarantee that using #toolbar=0 in the URL will work, as this is exclusive to browsers that use the Adobe viewer, it may be that other viewers even have similar parameters to maintain compatibility, but certainly not everyone follows that, such as browsers for MacOS browsers or Linux.

In most browsers it is possible to change the view, which also probably will not work with #toolbar=0, because the viewer is something apart from the browser, for example Firefox has its own viewer internally and that does not work with this #toolbar=0, see the result of:

<iframe
    src="sample.pdf#toolbar=0"
    width="900"
    height="200"
></iframe>

<br>

<embed type="application/pdf"
    src="sample.pdf#toolbar=0"
    width="900"
    height="200"
>

Firefox native pdf viewer

And even if it works in Firefox as well as Chrome with extensions, it is possible to change the PDF viewer to anything else that may not support this parameter.

Even if you can remove all the buttons you want, you can still copy your PDF, or images, because everything is downloaded to your computer before rendering, the user can simply press F12 to open DevTools (Chrome / Firefox), look the network tab and filter it to get all PDFs loaded on the current page and by DevTools it will copy the PDF to any folder of it.

There is no way to stop, it is only possible to hinder. As already seen neither "iframe" nor "embed" will solve, I suggest (it's just a suggestion) use PDF.js.

So you can create your own buttons, navigation and the like and everything will run in <canvas>, example:

var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf';

var pdfjsLib = window['pdfjs-dist/build/pdf'];

pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

var pdfDoc = null,
    pageNum = 1,
    pageRendering = false,
    pageNumPending = null,
    scale = 1.5,
    canvas = document.getElementById('pdf-example'),
    ctx = canvas.getContext('2d');


function renderPage(num) {
  pageRendering = true;

  pdfDoc.getPage(num).then(function(page) {
    var viewport = page.getViewport({scale: scale});
    canvas.height = viewport.height;
    canvas.width = viewport.width;

    var renderContext = {
      canvasContext: ctx,
      viewport: viewport
    };
    var renderTask = page.render(renderContext);

    renderTask.promise.then(function() {
      pageRendering = false;
      if (pageNumPending !== null) {
        renderPage(pageNumPending);
        pageNumPending = null;
      }
    });
  });

  document.getElementById('page_num').textContent = num;
}


function queueRenderPage(num) {
  if (pageRendering) {
    pageNumPending = num;
  } else {
    renderPage(num);
  }
}

/**
 * show previous page
 */
function onPrevPage() {
  if (pageNum > 1) {
    pageNum--;
    queueRenderPage(pageNum);
  }
}

document.getElementById('prev').addEventListener('click', onPrevPage);

/**
 * show next page
 */
function onNextPage() {
  if (pageNum < pdfDoc.numPages) {
    pageNum++;
    queueRenderPage(pageNum);
  }
}

document.getElementById('next').addEventListener('click', onNextPage);

/**
 * PDF async "download".
 */
pdfjsLib.getDocument(url).promise.then(function(pdfDoc_) {
  //Set loaded PDF to main pdfDoc variable
  pdfDoc = pdfDoc_;

  //Show number of pages in document
  document.getElementById('page_count').textContent = pdfDoc.numPages;

  renderPage(pageNum);
});
#pdf-example {
    border: 1px solid black;
}
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>

<div>
  <button id="prev">Previous page</button>

  <button id="next">Next page</button>

  <span>Page: <span id="page_num"></span> / <span id="page_count"></span></span>
</div>

<canvas id="pdf-example"></canvas>

Note that I used 1.5 to scale:

 scale = 1.5,

 ...

 var viewport = page.getViewport({scale: scale});

You can change this as needed. I recommend that you adjust it according to the view-port measurement (you can use window.innerWidth to calculate), but also make a minimum measurement, so it will be adaptive to different resolutions.

2
  • how to hide download icon in menu bar?
    – Ajay Takur
    Jan 22, 2021 at 11:07
  • 1
    Hi @AjayTakur! As i already said in the answer, there is no guarantee of removing buttons from the PDF reader plugins, the only guaranteed solution is to use something independent, like "PDF.js". Try it, adapt the example to your needs.
    – Korvo
    Jan 22, 2021 at 14:17
0

This works for me for hiding the pdf print view in react application

<iframe src={`${resumeUrl}#toolbar=0`} width="100%" height={500} />
1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 17, 2022 at 20:00
0

Yes, you can achieve seamless PDF embed with no toolbar. It is now possible in 2023 using Adobe Acrobat API:

https://developer.adobe.com/document-services/apis/pdf-embed/

You need to get a free API key here to integrate a script to your domain.

UI customizations here: https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos_ui/

Code example:

<div id="adobe-dc-view" style="height: 360px; width: 500px;"></div>
<script src="https://acrobatservices.adobe.com/view-sdk/viewer.js"></script>
<script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
        var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
        adobeDCView.previewFile({
            content:{location: {url: "https://acrobatservices.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
            metaData:{fileName: "Bodea Brochure.pdf"}
        }, {embedMode: "SIZED_CONTAINER"});
    });
</script>

Also, you can enable small overlay disappearing toolbar to download / print / go to page etc. Enjoy!

-1

Just append '#toolbar=0&navpanes=0' at last of your URL.

src = this.sanitizer.bypassSecurityTrustResourceUrl('data:application/pdf;base64,' + res.data + '#toolbar=0&navpanes=0');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.