• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 458
  • Last Modified:

Adobe Acrobat 5: addWeblinks()

I added the method addWeblinks() to a text field (as JavaScript):
var numWebLinks = this.addWeblinks();
When moving to another field (onBlur), Adobe messages 'Creating weblinks' in the status bar.
Unfortunately, weblink is not created (at least not visible and functional). The content of the field is "http://www.google.de".
How to get it run?
  • 3
  • 2
1 Solution
Karl Heinz KremerCommented:
The Doc.addWeblinks() method works only on "real" PDF content, and not form fields. What are you trying to accomplish (be as specific as posible)?
You may be able to use a different methanism to create the same effect (e.g. create a button that opens the selected URL).
go4javaAuthor Commented:
I've a form with various input fields. One is a TEXT field to keep a specific URL, entered (copied) by the user.
After leaving the field, it should automatically convert to a hyperlink, so that following users can simply click on the URL.
Karl Heinz KremerCommented:
It's not possible to do this in a one-step solution. First of all, this would only work with the full version of Acrobat (you need to modify the document and save it again, which is not possible in the free Reader). YOu also need to convert your field from a text input field to a link, which would mean that you can not update the link anymore once you've converted it to a link.
How about using two different form fields: One for the input, and one for the actual link? This way you can modify the document, and still modify the link if that's necessary.

Can you provide more information about what you want to accomplish with this? It sounds like you have two different user types for your document. There may be other ways to accomplish this, please provide as much inofrmation as possible.
go4javaAuthor Commented:
We are working with Acrobat 5, not the reader. Reader is for end-users only.
Soon, we'll get Acrobat 6...
If I follow the steps mentioned on top, the function seems to process (but the field will not be converted to a link - as it should).
The field with the link will be submitted and some other users will add more information to the form (each of them will submit accordingly).
Can't use 2 fields, one is a must...
Karl Heinz KremerCommented:
Your assumptions are wrong: The function is not supposed to convert a text field content to a web link.

Use this script as OnBlur action handler for your text field (you need to change the field names Text1 and potentially Button1 if you already use a field named "Button1"):

var f1 = this.getField("Text1");

// get the size and coordinates for Text1
var r = f1.rect;
var url = f1.value;

if (typeof f1.page == "number")
    var page = f1.page;
    var page = f1.page[0];

// set the text color to blue (to mark it as a link)
f1.textColor = color.blue;

// create a new button
f2 = this.addField("Button1", "button", page, r);

// set the action of the button to "go to URL"
f2.setAction("MouseUp", "this.getURL('" + url + "', false);");

// end of script

This will create a new button with an action of "getURL()" right on top of the original text field. This way, the button will be clicked when the user clicks on the text field. I'm also changing the color of the text in the text field to blue so that it looks more like a link.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now