Show a PDF document in a browser without the menu bar
Categories:
Displaying PDFs in Browsers Without the Menu Bar

Learn how to embed PDF documents in web browsers while suppressing the default toolbar and menu bar for a cleaner, more integrated viewing experience.
Embedding PDF documents directly into web pages is a common requirement for many applications. However, the default browser behavior often includes a toolbar or menu bar that can interfere with the desired user experience or design aesthetic. This article explores various methods to display PDFs in a browser, specifically focusing on techniques to hide or minimize these intrusive UI elements, providing a more seamless integration into your web application.
Understanding PDF Embedding Options
Browsers typically handle PDF files using their built-in PDF viewers or by relying on plugins. The level of control you have over the viewer's UI (like toolbars, print buttons, or download options) largely depends on the embedding method and the browser's capabilities. The most common way to embed a PDF is using an <iframe>
tag, which allows you to specify parameters in the URL to control the viewer's appearance.
flowchart TD A[Start] --> B{Choose Embedding Method} B --> C{`<iframe>` Tag} B --> D{PDF.js Library} C --> C1[Direct URL Parameters] C --> C2[Server-Side Proxy] D --> D1[Custom UI Control] C1 --> E[Hide Toolbar/Menubar] C2 --> E D1 --> E E --> F[Seamless PDF Display] F --> G[End]
Decision flow for embedding PDFs and controlling UI elements.
Using URL Parameters for UI Control
Many browsers and PDF viewers support URL parameters that can be appended to the PDF file's URL to control its display. These parameters are part of the PDF Open Parameters specification. While not universally supported by all browsers or PDF plugins, they are widely recognized by popular viewers like Adobe Reader and Chrome's built-in viewer. The most relevant parameter for hiding the menu bar is #toolbar=0
and #menubar=0
.
<iframe src="/path/to/your/document.pdf#toolbar=0&menubar=0&navpanes=0&scrollbar=0" width="100%" height="600px"></iframe>
Embedding a PDF with URL parameters to hide toolbar, menubar, navigation panes, and scrollbars.
#toolbar=0
is generally well-supported, other parameters like #menubar=0
or #navpanes=0
might not work consistently across all browsers (e.g., Firefox often ignores these parameters for security/accessibility reasons).Advanced Control with PDF.js
For scenarios requiring more granular control over the PDF viewer's appearance and functionality, using a JavaScript library like Mozilla's PDF.js is an excellent solution. PDF.js renders PDFs using HTML5 Canvas, giving you complete control over the UI. You can build a custom viewer interface around the PDF rendering, omitting any elements you don't want to display.
<!-- Basic integration of PDF.js viewer -->
<iframe src="/pdfjs/web/viewer.html?file=/path/to/your/document.pdf" width="100%" height="600px"></iframe>
<!-- To hide toolbar, you'd modify viewer.html or build a custom viewer -->
<!-- Example: viewer.html?file=/path/to/your/document.pdf#zoom=page-width&toolbar=0 -->
Embedding a PDF using the default PDF.js viewer. Customization requires modifying the viewer.html or building a bespoke viewer.
To truly hide the menu bar and toolbar with PDF.js, you would typically download the library, host it on your server, and then either modify the viewer.html
file to remove the UI elements or create your own HTML structure that loads the PDF.js core and renders the PDF without any default UI components.