Sunday, 9 January 2011

Disabling Read Mode for embedded PDF files

Those of you who are embedding PDF files into web pages (as an inline element of the HTML, not just a link) will no doubt have noticed that the browser plugins for Adobe Reader X and Adobe Acrobat X always use Read Mode by default - which results in the heads-up display (HUD) rather than the classic application toolbar.

While that's great for users who want a clean interface, your document may not be designed with Read Mode in mind - you may have content in a very small <embed> rectangle and want nothing at all other than a vertical scrollbar, or you may have a document where access to the full range of tools is necessary from the get-go. Unfortunately the decision to open in Read Mode is an application general preference (Preferences > Internet > Display in Read Mode by default) and you cannot change that using the initial view settings within a particular PDF file.

The Ninja can leap to the aid of website designers by revealing an undocumented trick.

The "normal" way to embed a PDF file in a web page uses the <embed> tag, as follows:

<embed src="MyFile.pdf" width="530" height="300" />

If you use that, you'll be at the mercy of Read Mode, so the file looks something like this:


If you add the parameter to control the toolbar visibility, Read Mode is disabled no matter what the user's preferences are:

<embed src="MyFile.pdf#toolbar=0" width="530" height="300" />

You can set toolbar=0 to hide it, or toolbar=1 to show it, but either way, the HUD is dead.

If you want to add other preferences, you can - for example this tag turns off the toolbar (and hence the HUD) and also turns off the scrollbar, despite the PDF having more than one page, but turns ON the navigation panes. You can navigate using your arrow keys, or mousewheel:

<embed src="MyFile.pdf#toolbar=0&scrollbar=0&navpanes=1" width="530" height="300" />

2 comments:

  1. I am using embedded PDF files as a way to easily display reports through a browser (FireFox). The actual PDF is about 10 pages long, but the HTML page is coded with the embed tag and uses the Open Parameters to display just a few aspects of the PDF, in an easy to read format. The annoying part is that the embedded PDF sections can accidentally be scrolled with the mousewheel, which ruins the look of the report in the browser. Is there a way to disable this?

    ReplyDelete
  2. It's not possible to disable mouse wheel responses using anything within the PDF file or the embedding HTML page. However if you set the initial view preferences of the document to "fit page" and "single page" rather than "single page continuous", mouse wheel events will flip up/down through the PDF a page at a time rather than scrolling it smoothly.

    ReplyDelete

All comments containing web links, promotional messages, adult content or offensive language will be rejected as spam.