These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Underlining words

sgrey
Registered: Oct 15 2008
Posts: 14
Answered

Hello,

I have a form where the user needs to be able to add an underline under specific words (from a list) and turn off the underline if it is no longer needed.

I have been able to do this by using two buttons:

'Object 1' contains the word

'Object 1 Underline' is a hidden, filled button below the word that has been collapsed so it just looks like a line.

'Object 1' is set to show 'Object 1 Underline' when clicked.

When you click 'Object 1 Underline' it hides itself.

This works, but it seems cumbersome, especially since there my be 50 or more words affected on each page and there might be 10-15 pages.

I wondered if there is a way to simply underline a word (as a text format feature) with some kind of toggle button.

I'm using Acrobat 9 on a Mac but do have access to LiveCycle Designer.

Thanks.

My Product Information:
Acrobat Pro Extended 9.1.1, Macintosh
nixopax
Registered: Feb 6 2009
Posts: 105
Hi sgrey,

Here's a way to do it:

Make a set of child fields with a parent named 'underline'. The fields child names are up to you. If you want to number them, or use the word that they contain, or some other naming convention. (i.e.: underline.hello [b]or[/b] underline.1)

Then you make a button to toggle the underline. To turn on/off the highlights for all the fields, here is the javascript:
var nField = this.getField('underline');if(nField.strokeColor == "T"){nField.strokeColor = color.black;}else{nField.strokeColor = color.transparent;}nField.borderStyle = border.u;

Now, let's say you wanted to only underline the word in a list. Well, in this case you have to specify the child name. So if you commit selected value immediately of the list, then you can use the event.value in a function to do each underline individually.

Let's say you have 3 fields underlining the words: 'Hello', 'Thanks', 'Bye' and therefore, are named: 'underline.Hello', 'underline.Thanks', 'underline.Bye' respectively.

The list has these as the item value: 'Hello', 'Thanks', 'Bye'
The list has a custom keystroke script set under the Format tab:
if(event.willCommit){var nField = this.getField('underline.' + event.value);if(nField.strokeColor == "T"){nField.strokeColor = color.black;}else{nField.strokeColor = color.transparent;}nField.borderStyle = border.u;}

One thing you have to remember when it comes to names of fields: [b]Case dependency[/b]! If you have a field named 'underline.Hello', it is NOT the same as 'underline.hello' Keep that in mind when you make your list and the item/export value has to be the same otherwise it'll attempt to target another field.
sgrey
Registered: Oct 15 2008
Posts: 14
Thanks, nixopax.

I was able to adapt your first script to be just what I needed.
HLillywhite
Registered: Jul 30 2009
Posts: 9
I'm trying to just underline test in a pdf (using Acrobat 9), but the underline tool doesn't seem to be working. There is no security on the document. What am I doing wrong?
sgrey
Registered: Oct 15 2008
Posts: 14
Hi HLillywhite,

Are you in Acrobat Professional or Acrobat Reader (the free one)? Is this existing text on the page, or is it text that you are entering in a field?
HLillywhite
Registered: Jul 30 2009
Posts: 9
Hey sgrey, thanks for getting back to me. I found the problem. It was a scanned pdf that hadn't been OCR'd. I did that and the underline, highlight, etc., started working. Different question for you though...how do you protect a pdf so that the text edit function can't be used on it by someone else?
sgrey
Registered: Oct 15 2008
Posts: 14
No problem.

I know that if you go to File...Properties... and choose the 'Security' tab, you can change the security setting to restrict any document editing (and other stuff) if the user does not have the correct password. there may be other ways as well. If this does not work, you may want to try searching the site or starting a new thread.