Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Hyperlinks in Form Objects

The newest releases of Adobe LiveCycle Designer and Adobe Acrobat/Reader (versions 8.2 and 9.0, respectively) add support for hyperlinks in form objects. You can set hyperlinks to websites, files or email addresses in text objects and field captions.

Text Objects

Creating hyperlinks is easy. Consider the following text object (I’ve bolded one word to highlight the fact that hyperlinks work with plain and/or rich text):

To set “Adobe LiveCycle Developer Center” as a hyperlink, simply highlight the text and choose “Insert Hyperlink” from the context menu or choose “Insert > Hyperlink” from the top-level menu. You’ll get the following dialog where you can specify the URL or email information (notice you can even set the subject of the new email if you set an email hyperlink):

That’s it! Pretty simple. Once the hyperlink is created, you can edit it again by choosing “Edit Hyperlink” or you can remove it by choosing “Remove Hyperlink” from the context menu. You can also choose “Open Hyperlink” to test that the link is valid.

Over in Acrobat/Reader, when the user hovers their mouse over the hyperlink, the cursor will change to a small hand with a “w” over it and a tooltip will appear indicating the hyperlink destination:

Clicking on the hyperlink will result in a security dialog providing the user with the opportunity to “allow” or “deny” Acrobat’s request to open the link. (Before you ask, the security dialog cannot be avoided. I did notice that it sometimes doesn’t appear when you click on a hyperlink within the context of Designer’s “PDF Preview” tab but it will definitely appear when the form is run within Acrobat/Reader on its own.)

Field Captions

As I mentioned earlier, you can also set hyperlinks on field captions. This could be really handy, especially to provide extra help. Consider the scenario where a drop down list is asking a user to choose a policy. It might be useful to provide a way for the user to obtain more information about each policy. Before the hyperlink feature was added, you would’ve had to use a button with the following script in its click event:

xfa.host.gotoURL("http://www.somewhere.com/policy-help/");

That doesn’t look really nice. Sure, you could take the time to format the button’s appearance to remove the highlight, remove the border, remove the background color and set the font to “blue + underline” but that’s a lot of work. Now you can just make a hyperlink out of the word “policy” with just a couple of clicks (and it looks much better too):


Posted by Stefan Cameron on October 6th, 2008
Filed under Acrobat,Designer,Tutorials
Both comments and pings are currently closed.

27 Responses to “Hyperlinks in Form Objects”

  1. Xancholy on November 3rd, 2008

    Hi Stefan,

    Thanks for the great info !

    I have added a text field (set to rich text format) in my dynamic pdf.

    I am trying to add a hyperlink within that textfield by typing say, “http://www.yahoo.com”
    or by pasting an actual hyperlink from a Word document.

    Both methods fail.

    How can I create a hyperlink within a textfield set to richtext ?

    Thanks for any help !

  2. Stefan Cameron on November 10th, 2008

    Xancholy,

    Unfortunately, this is a little complicated since Designer’s UI doesn’t let you do it via the “Object palette > Value tab > Default Value property”. You have to generate an XHTML string to load as XML into the field’s //value/exData node which contains the rich text value you see in the field’s content area.

    For example, if you wanted to initialize a rich text field to have a link in it, you would do this in its Initialize event (shown here in JavaScript):

    this.value.exData.loadXML('<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p><a href="http://www.adobe.com/">link</a></p></body>');
  3. KVSrikanth on January 17th, 2009

    Hi Stefan,

    I want to use a hyperlink, but this hyperlink should open a new browser window. Is this possible with gotoURL() method.

  4. Stefan Cameron on January 21st, 2009

    KVSrikanth,

    Unfortunately, you can’t get a Click event from a hyperlink such that you could then use the xfa.host.gotoURL method to open it the way you want. If you need this type of control, I’m afraid the only way I know is to style a button so that it looks like a hyperlink (e.g. remove fill and set font to “blue+underline”) and add an xfa.host.gotoURL call in the button’s Click event. The only problem with this approach is that the “hyperlink” can’t be inside some other text (e.g. inside a paragraph).

  5. Mama on February 25th, 2009

    I have no ‘event’ with my button. I can’t see where to make the button a hyperlink with the ‘goTo’ event handler. Not one thing I’ve read anywhere helps. When I paste a link into Designer, it grabs whatever the next text word is so the link doesn’t work. There is no ‘insert – hyperlink’ available.

  6. Stefan Cameron on February 25th, 2009

    Mama,

    Are you using Designer 8.2 with Acrobat/Reader 9? As I mentioned in my post, the Hyperlink feature is only available as of those versions.

  7. Stacey on May 18th, 2009

    I am successful in inserting a hyperlink in text fields. The one I use is the ability to download the Acrobat Reader 9.0 so they can complete, save and send back the completed LiveCycle 8.1 Designer form.

    Then I add the Extended Reader Feature.

    However, I keep losing hyperlinks. Some forms keep it and others do not???

    Any suggestions or reason why I would lose the links?
    Thanks for your time.

  8. Stefan Cameron on May 25th, 2009

    Stacey,

    Could you be more specific about what you mean by “losing hyperlinks”?

    What exactly do you mean by “Extended Reader Feature”? Is this the “Extended Features in Adobe Reader” in Acrobat or is this LiveCycle Reader Extensions ES and if so, what rights are you adding?

  9. Sedat Reyhan on August 21st, 2009

    Yes i am also losing hyperlinks for xdp files in workspace.

    I design a simple form “pdf”, add a hyperlink, it is shown in workspace.. But if it is “xdp”, hyperlink s lost in workspace, only a text i see. Could you advice ?

  10. Stefan Cameron on August 23rd, 2009

    Sedat Reyhan,

    It sounds like your XDP form isn’t being rendered as an XFA 2.8 document. It must be rendered in XFA 2.8 and must be viewed in Acrobat/Reader 9.0 in order for the hyperlinks to work. Otherwise, you will only see text (as you’re describing). When your form is already a PDF (i.e. already rendered, to a certain degree), it must have been saved as an XFA 2.8 form.

    Another possibility is that your XDP form has some form compatibility setting issues that are preventing it from being rendered as an XFA 2.8 form, even though you may have set it to target Acrobat/Reader 9.0 (XFA 2.8).

  11. Greg Pisocky on October 8th, 2009

    Hey Stephan,

    Interesting question has come up. LiveCycle Designer insists on rendering the hyperlinks as blue underline text. Anythoughts for those who want an alternative to blue underlined hyperlinks?

  12. Stefan Cameron on October 12th, 2009

    Greg Pisocky,

    Based on my testing, you can use the Font palette in Designer 8.2 to format the hyperlinks as you wish however Acrobat/Reader will continue to render them as blue underlined text regardless of formatting applied (and visible at design-time in Designer). I don’t know of a way to get Acrobat/Reader to respect the formatting (looks like a bug to me).

  13. Weston on November 9th, 2009

    I have created a hyperlink by manipulating a regular button with the goToUrl method on the click, however it will not open in a new browser window. Instead it opens within livecycle and the user cannot go back to the form without reopening the original form. Anyway to open in a new browser? thanks

  14. Stefan Cameron on November 12th, 2009

    Weston,

    You can use the app.launchURL([url], true) Acrobat API to open the link in a new window.

  15. Aaron Williams on November 13th, 2009

    I am using a button object with no caption and no border so its invisible. I then use the app.launchURL([url], true) script (thanks Stefan Cameron) on the click event for the invisible button to create a hotspot. You can then put this hotspot over anything you want linked…

  16. Mark Dertzbaugh on February 26th, 2010

    How do you allow a user to paste a functional URL in a text field for a PDF form? I know how to create a hyperlink for the form field name, but not how to allow the user to enter a URL in a user-defined field.

    Thanks!

  17. Stefan Cameron on March 3rd, 2010

    Mark Dertzbaugh,

    First, the text field’s content type would have to be “Rich Text”. Then, when filling the field in Acrobat/Reader, click in the field and press the [Ctrl + E] sequence to show the Formatting toolbar. You should be able to use that to enter a hyperlink.

  18. Cindy Mawhinney on March 26th, 2010

    Hi. I am using Adobe Pro 9, LiveCycle 8.2 and Adobe Reader.

    I am having difficulty with tabbing order: tabbing to user input fields is fine, however, I have a regular text box with a hyperlink in it and when viewed in Reader, when the user is tabbing it will take them (at random) in the middle of tabbing to the hyperlink and then go back to tabbing through the input fields.

    In LiveCycle tab order, the hyperlink does not appear so it’s not something can move to the very bottom of the list so it’s the last place to tab to. Any help would be greatly appreciated.

  19. Stefan Cameron on April 3rd, 2010

    @Cindy Mawhinney,

    Designer 8.2 and Reader 9.0 introduced a revamped Tab Order feature which should help you get around this issue. The new feature will let you set the tabbing sequence of the text object that contains the hyperlink.

    Your comment inspired me to add the new “Text Objects” section at the end of the tutorial. Thanks!

  20. mika on September 7th, 2010

    I’m using Acrobat Professional 9 Pro Extended, which includes LiveCycle.

    I’ve noticed that I can add hyperlinks in this version of LiveCycle; however, when the form is opened by a user who has Acrobat Pro 8, they are unable to see the hyperlinks (instead of being blue, underlined, clickable text, the text is just black and cannot be clicked on). This presents an issue because we have many users with numerous combinations of Acrobat/Adobe Reader starting with Acrobat Pro 7 all the way to Pro 9 and Reader 7 to 9. If I download Reader 9 forthe users with Acrobat Pro 7 or 8, then they can see the links. All users with Acrobat Pro 9 can see the links.

    Is there something I am doing wrong? Or is there something I can do to ensure that the links are clickable/usable for users with Reader/Acrobat of a lower level? Has anyone else run into this issue?

  21. Stefan Cameron on September 10th, 2010

    @mika,

    Unfortunately, hyperlinks are only supported as of version 9.0 of Adobe Acrobat and Adobe Reader. Previous versions do not support hyperlinks.

    The only backward-compatible solution is to make your own hyperlinks using buttons that have no appearance (no border, no fill) and place them carefully over the text you want to act as a hyperlink. Then you make the text blue and underlined like hyperlinks usually are. Finally, you set the button’s Click script to be “app.launchURL(‘http://server/’);”.

    It’s not pretty, but it’s the only way you’ll get hyperlink-like behaviour in earlier versions of Acrobat/Reader.

  22. Brian on November 3rd, 2010

    Hi Stefan,

    I am using LiveCycle ES2 9.0. I want to add a hyperlink at the top of the XDP form to link to another section further down in the form. This section when it is rendered could be on another page altogether.

    Also wondering if the link will work when the form is rendered as HTML using HTMLFormRenderer service?

    Thanks!

  23. Stefan Cameron on November 6th, 2010

    @Brian,

    Unfortunately, it is not possible to use the hyperlink feature to link to another place in a form. You can only use it for external (i.e. email or HTTP) links.

    To link to another place in a document, you basically have to use a button, make it look like a hyperlink (remove the background fill, set the font to blue, underlined) and set its Click event to set focus to a visible form object (field or button) that is located at the position in the document that you want to display when user clicks on the “hyperlink”. You can set focus to a form object like this (keep in mind that it must be an object that can receive keyboard input/focus so a rectangle won’t work):

    xfa.host.setFocus(formObject.somExpression);

    where “formObject” is the form object you want to set focus to.

  24. Connie on November 9th, 2010

    Hi Stephan, question. I have a client who created a form in Acrobat. She’s asking me if I can make a form field auto hyperlink the users email and website address when she receives it. Is this possible because I have been unable to find an answer. Thanks!

  25. Stefan Cameron on November 15th, 2010

    @Connie,

    I’m not sure I understand what you mean by “auto-hyperlink the users email and website address when she receives it.” Can you explain this in more detail? Does the auto-hyperlink have to happen when the form is opened? Where does the user data come from?

    Also, was this form created in Adobe LiveCycle Designer that ships with Acrobat or is it an AcroForm (created with Acrobat’s form design tools)?

  26. Brian on November 30th, 2010

    Hi Stefan,

    Thanks for the helpful post. I’ve got another question…

    How can I build dynamic hyperlinks in XDP forms? The hyperlink function provided in designer takes static hyperlinks (known at design time). If however, i have to provide a URL such as “www.ups.com/waybill=XXX”, where XXX is a run time value for a tracking number. How can I accomplish this?

    I tried using a button and javascripting on its “click” event to launch the URL i need. This works in designer preview but does not work when the XDP is rendered as PDF using process workflows – generatePDFOutput service. The button caption appears as static text (no hand icon on mouse-over).

    Thanks!

    Thanks!

  27. Stefan Cameron on December 3rd, 2010

    @Brian,

    You can create hyperlinks at runtime by setting the rich text value of a text object: At design time, make sure the text object has some rich formatting inside it so that the text object’s value element contains an one-of-child property. Then, at runtime, load new rich text (XHTML) into the node where the XHTML contains the markup for the new link. See this comment for sample code.

    As for the generatePDFOutput service issue, make sure that the PDF being generated is interactive or dynamic. If you generate a static PDF, none of the fields will work.