12 Replies Latest reply on Mar 13, 2008 6:59 PM by Patrick Leckey

    Unique Highlighting Elements in Form Fields

      Hi all

      My boss is asking me to build an interactive PDf file for in-office use that has some unique highlighting features. She wants the viewer to select an option on the PDF file, and when they make that selection, a box or rectangle outlines the choice. When the administrator saves the document to archive, and production opens it up to examnine it, the "boxed" selections will give them the options the customer wants.
      I've already been to support for this, and have been informed that Acrobat does not have a default script or action that does this, but they suggested that I come to this forum and ask the Acrobat scripting community if there is some Java script out tere that will evoke the effect that I described above, and if so, where can I access it?

      Thanx in advance!

      Paul
        • 1. Re: Unique Highlighting Elements in Form Fields
          evil8
          To answer your question properly we would need to know more about how the form operates. How are your selections and choices made on the form? Check Boxes, Radio Buttons and/or Text Fields? Also what verson of Acrobat are you using? That would at least get us started. Also see the Acrobat JavaScript Guide for your version of Acrobat. There are a few people lurking about in here that would be more than willing to projects like this for a fee.
          • 2. Re: Unique Highlighting Elements in Form Fields
            Ramon F Herrera Level 1
            Paul:

            I am trying to solve a very similar problem. What you should do is to create all the framing rectangles in advance, and use JavaScript code to turn on and off their visibility.

            frame1.hidden = true;
            frame2.hidden = false;

            The problem that remains is how to retrieve the name of the rectangle ("frame1"), as they seem to be sort of anonymous.

            -RFH
            • 3. Re: Unique Highlighting Elements in Form Fields
              Ramon F Herrera Level 1
              It seems that annotations such as ovals, rectangles, etc. don't have a "hidden" attribute, but they have an "opacity" instead. So you should do this:

              frame1.opacity = 0;

              The question remains, though: how the heck do we get the name (pointer, handle, whatever) "frame1"?

              -RFH
              • 4. Re: Unique Highlighting Elements in Form Fields
                If the choice is a field, you could use change the color and outline when an option is selected similar to the following:
                if (<option is selected>){
                this.getField(fld.name).strokeColor = color.dkGray
                this.getField(fld.name).lineWidth = 1 //thin
                }else{
                this.getField(fld.name).strokeColor = color.red;
                this.getField(fld.name).lineWidth = 2 //medium
                }
                • 5. Re: Unique Highlighting Elements in Form Fields
                  Ramon F Herrera Level 1
                  Thanks for your excellent posting, Marcia - I didn't know we have such capabilities.

                  The main question remains, though...

                  > If the choice is a field

                  What if the highlighted element is not a field, but an annotation like an oval or rectangle? Can JavaScript get a handle on the annotation? Is this problem solvable with JS or we have to resort to the big guns and use a plugin?

                  -RFH
                  • 6. Re: Unique Highlighting Elements in Form Fields
                    Level 1
                    You can create annotations and change the properties. See JavaScript for Acrobat API Reference.
                    The question is what is the user selecting? a field, text what?
                    • 7. Re: Unique Highlighting Elements in Form Fields
                      Ramon F Herrera Level 1
                      > You can create annotations and change the properties.

                      Oh, I see. I guess the question is this. What if the annotation has been already placed, interactively with Acrobat Professional (or programmatically with an SDK) on the document? Then we want to use JavaScript to highlight and dim some of them. Is there a way to use JavaScript and ask the document: "please give me the handles to all the annotations you have"?

                      Thanks!

                      -RFH
                      • 8. Re: Unique Highlighting Elements in Form Fields
                        Patrick Leckey Level 3
                        this.syncAnnotScan();

                        var annots = this.getAnnots({
                        nPage:0,
                        nSortBy: ANSB_Author,
                        bReverse: true
                        });

                        console.show();
                        console.println("Number of Annotations: " + annots.length);

                        var msg = "%s in a %s annot said: \"%s\"";
                        for (var i = 0; i < annots.length; i++)
                        console.println(util.printf(msg, annots[i].author, annots[i].type, annots[i].contents));

                        Just as reading the JavaScript API Reference would have given you the above information, you can further read the Annotations class in the JavaScript API Reference to find out other properties of an Annotation object returned from the getAnnot or getAnnots methods.

                        > The question remains, though: how the heck do we get the name (pointer, handle, whatever) "frame1"?

                        It even has a "name" property.

                        Even though it is included with the SDK, so if you have the SDK you have this document, here is a direct link to the JavaScript for Acrobat API Reference. You'll find a lot of information about JavaScript for Acrobat APIs in there.

                        http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf
                        • 9. Re: Unique Highlighting Elements in Form Fields
                          Ramon F Herrera Level 1
                          What would we do without you, PDL?

                          No need for "Acrobat and PDF Development for Dummies", with you around. :-)

                          Now, seriously: my JavaScript book is outdated, hardcopy, and the mail in this country where I am physically doing a project now, simply doesn't work.

                          Thanks!

                          -RFH
                          • 10. Re: Unique Highlighting Elements in Form Fields
                            Patrick Leckey Level 3
                            What does having an old JavaScript book have to do with having read the JavaScript for Acrobat API Reference? It's a PDF that comes with the SDK when you download it.

                            Here is some night-table reading to get you through those long mail-less nights:

                            http://www.adobe.com/devnet/acrobat/?navID=documentation

                            Again, all of the above documentation comes with the SDK when you download it (or have it mailed to you) but so many people lately seem to just up and start using the Acrobat APIs without having read a thing about it, and then complain that they can't get it to work the way they want.

                            I am by no means a world-class developer like Aandi and yet I can still answer a good chuck of questions simply because I've read the documentation.
                            • 11. Re: Unique Highlighting Elements in Form Fields
                              Ramon F Herrera Level 1
                              > so many people lately seem to just up and start using the Acrobat APIs without having read a thing about it

                              That is a clear indicator of the massification that PDF is undergoing. First, there was massification among users and now, consequently, among developers.

                              -RFH

                              "When people lead, leaders will follow"
                              • 12. Re: Unique Highlighting Elements in Form Fields
                                Patrick Leckey Level 3
                                Is it the people or the leaders who have read the documentation?