.NET Tips and Tricks

Blog archive

Open PDF files Where (and How) You Want from a URL

It's not unusual to include a link in your page with a URL that points to a PDF file to let your users view the file on their computer. However, you can also control, through the URL, where and how the PDF file is displayed: just add a hash/pound sign (#) and some parameters to the PDF's URL.

For instance, the page parameter lets you open the PDF file at a specific page. This example opens the file at page 3:

http://mysite.com/userguide.pdf#page=3

You can also set up a search term for the user and position the view on the first appearance of the term (with the term highlighted) using the search parameter. This example searches for the word "test":

http://mysite.com/userguide.pdf#search=test

You're not limited to just positioning the user in the document. You can also specify how the document is to be displayed by using the view parameter. You can also combine parameters using the ampersand (&). This example repeats the search from the previous example but also fits the whole page into the view:

http://mysite.com/userguide.pdf#search=test&view=fit

Additional parameters let you turn on (or off) toolbars, panes, and draw highlight boxes around arbitrary text. Adobe has a document (in PDF, of course) describing all of the options.

Thanks to Larry Raby for letting me in on this!

Posted by Peter Vogel on 10/03/2012


comments powered by Disqus

Featured

Subscribe on YouTube