Hide/Disable download button on Chrome PDF Viewer

Hide/Disable download button on Chrome PDF Viewer

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Hide/Disable download button on Chrome PDF Viewer

When a client insists on "securing" a PDF by hiding the download button in the Chrome viewer, they are often asking for something fundamentally impossible to achieve purely through frontend means. You might see success disabling the print button using specific FPDF protection scripts or CSS hacks like display: none applied via DevTools, but these measures do not stop the underlying functionality of the PDF specification. The file is still there; the browser just isn't showing the UI element that triggers the save action immediately.

The core issue lies in how modern browsers handle PDFs. When you open a PDF directly from the URL using window.open, Chrome renders it using its built-in PDF viewer (often powered by the Chromium Embedded Framework or similar internal mechanisms). This viewer is sandboxed. It does not load your website's CSS, nor can you inject JavaScript into that new window simply because it was opened by a script on the parent domain.

Attempting to modify the DOM of the newly opened window—such as adding display: none to the download button element—is technically blocked by the browser's same-origin policy and sandboxing rules. Even if you could somehow access the document object model of the new window, the PDF viewer is a native application running inside the browser process, not a standard HTML page rendered from your server's response. Therefore, any CSS or JS manipulation attempted on the parent page has zero effect on the UI controls within the child window.

If the goal is to prevent users from seeing the download icon, the only reliable method that actually works across browsers like Chrome is to force the PDF to render inside an <iframe> on your own server, rather than opening it in a new window. By embedding the PDF view directly into your application, you gain control over the surrounding HTML and can apply custom CSS to hide specific UI elements if the browser supports them.

However, there is a significant trade-off here. When you embed a PDF in an iframe, the browser's native download button might still exist in the toolbar of the PDF viewer itself, depending on the browser version. Furthermore, hiding the button does not disable the keyboard shortcut Ctrl+S or the right-click context menu option to "Save As." An informed user can bypass these visual obstacles instantly.

If you proceed with embedding the PDF to attempt UI control, you must ensure your server serves the correct MIME type (application/pdf) and sets appropriate headers to prevent caching issues that might expose the raw file download path. In a Laravel application, for instance, you would render the view containing the iframe in your Blade template:

<iframe src="/path/to/your/document.pdf" width="100%" height="800px"></iframe>

You can then style the parent container or specific overlay elements to obscure the viewer's controls, though this relies heavily on the browser's implementation and may break with updates.

Ultimately, you must manage client expectations. There is no CSS property, JavaScript snippet, or server-side header that can truly disable a PDF's download capability while keeping it viewable in the browser. The FPDF script mentioned for disabling print functionality affects the metadata inside the file, which stops users from printing from the PDF viewer if the viewer respects those flags, but it does not alter the Chrome UI toolbar. If the client considers hiding the button a necessary security measure, they need to be informed that true protection requires either restricting access via authentication or serving the document in a format that renders within your site's controlled environment, understanding that visual obfuscation is not a security feature.

Our network