Friday, May 8, 2009

Inline Buttons: How to make a URL in a PDF Underline on Hover

PDFs have long been my favorite online medium of choice, from a designer's standpoint at least. There are no hacks, no browser issues, no cross compatibility differences. I can design a page and things stay where I put them.

However, there are some aspects of web pages that are not easily duplicated in a PDF. Since the Adobe acquisition of Macromedia, media such as flash can now be embedded in a PDF. However, seemingly less complicated features of web pages cannot be replicated in a PDF. At least not very easily.

PDF hyperlinks are typically within body text. I have often wanted to have my PDF hyperlinks be a little more noticeable, but not with a big tacky underline. This is possible in web sites by using cascading style sheets, but it is not so simple to replicate in a PDF. However, there is a way to replicate this feature, and to do so, we will be using the button palette.



In InDesign, text within a text frame can be styled with paragraph and character styles, but it takes a few extra steps to create a rollover effect for a span of text within a text frame.

  1. Highlight the piece of text you want to create a rollover for.
  2. Cut it out and place it in it's own text frame.
  3. Fit frame to content. That is because the button size will be based on the size of your text frame.
  4. Create a new character style for what the text will look like in its hovered-upon state.
  5. Select the text frame and create a button from it.

  6. Click on the rollover pane of the buttons panel. The button serves as a sort of container for both of its states. Both states can be stylized and manipulated independently, as can the button itself. To either of the states, or to the button as a whole, you can add a drop shadow, varying levels of transparency, any any number of visual effects.
  7. Now stylize the text with the new rollover character style. You may find that if you use an underline, you may need to expand the text frame just a touch. Note that the two states of the button must now must be manipulated independently.
  8. So if you need to make the text frame larger, you'll need to do it to both the normal and the rollover state of the button. If you find that your text effects result in overset text, it is a good idea to undo few steps and make the original text frame just big enough to house the effects you're going to apply. That way, you won't have to make both the normal and rollover text frames larger. This is important because if you don't make the sizes of both the normal frame and the rollover frame match exactly, the text will jump around inside the frame when you hover over it. And that's just tacky.
  9. Once you text is styled for both states (normal and rollover), you're ready to put the text back in it's place within the flow of the body copy. So, select the button and cut it.
  10. Place your text insertion point back into the spot you originally cut the link from. Paste the button. The button text may not rest exactly at the baseline with the rest of the text, so nudge it down a little to make it match.
  11. Now, export a PDF with the interactivity check box checked. When you mouse over the hyperlink, it should now have a rollover state.
This is a fairly labor-intensive technique, and probably isn't suitable for documents containing hundreds of links. However, it is a nice technique to dress up a special PDF. Click here for an example of the technique in action.