11 Replies Latest reply on Dec 8, 2010 2:01 PM by RainbowChunChunChang

    Create a simple running marquee. Assume there is a text field named “marquee”. The default value of

    RainbowChunChunChang Level 1

      Sorry if this question is too stupid or has already been asked.

       

      From the acrobat reference, the following is needed to run an example.

       

      Create a simple running marquee. Assume there is a text field named “marquee”. The default value of this field is “Adobe Acrobat version 8.0 will soon be here!”.

       

      I prefer something which I can put in debugger and run rightaway to see its result and work on the rest of the example.

       

      Thanks

      Rainbow Chang

        • 1. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
          George_Johnson MVP & Adobe Community Professional

          I don't understand the question. Why can't you use the code given to you in the JavaScript reference?

          • 2. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
            RainbowChunChunChang Level 1

            There is no code in the reference. The code there uses this and this is assumed.


            The other code uses such an object as in this snippet

             

            // Document-level JavaScript function
            function runMarquee() {
            var f = this.getField("marquee"); // ................................ you cant getField unless you have addField.

             

             

            If you need further clarifications ... I could try again .

             

            The problem is : again


            Create a simple running marquee.

            Assume there is a text field named “marquee”.

            The default value of this field is “Adobe Acrobat version 8.0 will soon be here!”.

            • 3. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
              George_Johnson MVP & Adobe Community Professional

              Well, you do need a field in the document to display the marquee text. You cannot display such a thing in the JavaScript console, if that's what you're wanting.

              • 4. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                gkaiseril MVP & Adobe Community Professional

                Have you looked at the entire example in the Acrobat JS API Reference underr the 'setTimeOut' property of the 'app' object?

                 

                You need to create a text field to scroll, a start action button,  and end action button as well as a document level script to shift the text witin the text field.

                 

                Create a simple running marquee. Assume there is a text field named "marquee". The default value of this field is "Adobe Acrobat version 8.0 will soon be here!".

                 

                // Document-level JavaScript function

                function runMarquee() {

                var f = this.getField("marquee");

                var cStr = f.value;

                // get field value

                var aStr = cStr.split(""); // Convert to an array

                aStr.push(aStr.shift());// Move first char to last

                cStr = aStr.join("");// Back to string again

                f.value = cStr;// Put new value in field

                }

                 

                // Insert a mouse-up action into a "Go" button

                run = app.setInterval("runMarquee()", 100);

                // stop after a minute

                stoprun=app.setTimeOut("app.clearInterval(run)",6000);

                 

                 

                // Insert a mouse-up action into a "Stop" button

                try {

                app.clearInterval(run);

                app.clearTimeOut(stoprun);

                } catch (e){}

                 

                The Stop button code is protected with a try/catch construct. If the user clicks the Stop button without having first clicked Go,

                 

                run and stoprun will be undefined and the Stop code will throw an exception. When the exception is thrown, the catch code is executed. In this example, the code does nothing if the user clicks Stop first.

                 

                You can download the Marque Sample.

                 

                If you want to start the marquee through the JS console then you need to enter the code for the start button and execute it.

                 

                I would create a more generalized set of functions that are not specifice to a given text field or time limit.

                • 5. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                  RainbowChunChunChang Level 1

                  Is it correct that if you put some text like this in javascript console and then execute it, it will create a field ?

                   

                  this.addField("BUTTON5","button",0,[200,600,225,620]).fillColor = ["RGB", (192 / 255), (192/255),(192/255)];

                  • 6. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                    gkaiseril MVP & Adobe Community Professional

                    But you still need to add the script action to the button, text or icon, borders, etc.

                     

                    And I find it easier to crate fields through the UI than in JavaScript or raw post script.

                    • 7. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                      RainbowChunChunChang Level 1

                      I downloaded your document called

                       

                      Date Arithmetic in Acrobat PDF Documents by George T. Kaiser

                       

                      but it has the word marquee not even once.

                       

                      (a) What is a marquee as meant in that example ?

                       

                      > But you still need to add the script action to the button, text or icon, borders, etc.

                       

                      > And I find it easier to crate fields through the UI than in JavaScript or raw post script.

                       

                      (b) But this is what I am asking first a little help to improve (my one liner BUTTON5 which works) by adding a text label to it such as ROSE so it goes to the named destination which I will create.

                       

                      I also need to know how to enter a javascript file which will load these definitions only once. Simplest possible code or staged improvement.

                       

                      I trust that you are able to help since you took the pains to seach my partial snipped in the reference manual and pasted its entire code.

                       

                      Thanks,
                      Rainbow Chang

                      • 9. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                        RainbowChunChunChang Level 1

                        The file showed me the marquee but the replies have still not answered my original question of how to programmatically add  the buttons as stated below

                         

                        > But you still need to add the script action to the button, text or icon, borders, etc.

                         

                        > And I find it easier to crate fields through the UI than in JavaScript or raw post script.

                         

                        > You need to create a text field to scroll, a start action button, and end action button
                        > as well as a document level script to shift the text witin the text field.

                         

                        (b) But, this is what I am asking, first a little help to improve (my one liner BUTTON5 which works) by adding a text label to it such as ROSE so it goes to the destination which I will create.

                         

                        I also need to know how to enter a javascript file which will load these definitions only once. Simplest possible code or staged improvement.

                         

                        (c) Did you obtain the file from the SDK ? What is the source of this example file ? Is there a place with all the example files of code in the SDK doc ?

                         

                        (d) Another question is that your file demands to be saved as soon as it is opened. This means it is modifying itself and where is this happening and why ?

                         

                        I trust that you are able to help since you took the pains to seach my  partial snipped in the reference manual and pasted its entire code from the ref manual and also the file showing marquee in operation.

                         

                        Thanks,
                        Rainbow Chang

                         

                        P.S. I have felt glitches in the console operation. sometimes due to name conflict.

                        • 10. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                          gkaiseril MVP & Adobe Community Professional

                          >  (c) Did you obtain the file from the SDK ? What is the source of this example file ? Is there a place with all the example files of code in the SDK doc ?

                           

                          No I created it completely in Acrobat and used only the code provided by the Acrobat JS API Reference. I used the Forms Toolbar to make the text field and the buttons. Selecting the field and right mouse clicking brings up the context menu for the field and one can select the "Properties" option and then there are a number of tabs that allow for modifying the form field which provide access the default value of the text field, labels for the buttons, add actions for the buttons..  I used the 'Touchup Text" tool to add the text to the PDF.

                           

                          > (b) But, this is what I am asking, first a little help to improve (my one liner BUTTON which works) by adding a text label to it such as ROSE so it goes to the destination which I will create.

                           

                          The label of a button is just that, a viewable label. You need to add an action to a button's triggering event. These actions can be anything from noting to any of the drop down choices for the 'select action' drop down box. If you select JavaScript then the editor for Acrobat is opened and you enter the necessary code.

                           

                          > I also need to know how to enter a JavaScript file which will load these definitions only once. Simplest possible code or staged improvement.

                           

                          Unless you need the JavaScript to be processed during the opening of Acrobat/Reader so the functions or variables are available to any opened PDF (a global scope), most JavaScript is contain within the PDF file and not an application folder. If you create JS in application level folders, then each user will need those files installed on their system.

                           

                          How one adds JavaScript to a PDF depends upon the version and what type of item you are dealing with and what type of code you are running. Possible field JavaScript includes, formatting, keystrokes. calculations. mouse actions, tab actions, entering and exiting the field. Page actions include opening and closing the page. Bookmarks include all sort of actions, and fields have various actions. There are also printing, opening, closing actions, and scripts that apply to the entire PDF and are executed upon opening to can be called by any other action of the PDF.

                           

                          >(d) Another question is that your file demands to be saved as soon as it is opened. This means it is modifying itself and where is this happening and why ?

                           

                          If you carefully read the document level code function that moves the text, comments are preceded by the '//' characters, you will see that the value of the 'marquee' field is obtained. Then that text is split into an array in which each element of the array is one character of the text string. The first element, character, is then 'pushed' at the end of the shifted array of characters. The new array is then reassembled to a character string by use of the 'join' method and that new string value is placed back into the value of the 'marquee' field. This is a change in a field value and any change in a field value will 'dirty' the PDF, mark the PDF as having been changed, and this triggers a question for saving the PDF.

                           

                          There are a number of sites that provide information about scripting PDF files, Planet PDF, Acrobat Users Community, PDFScripting.com. There are a number of books about creating PDF forms by Ted Padova.

                          1 person found this helpful
                          • 11. Re: Create a simple running marquee. Assume there is a text field named “marquee”. The default value of
                            RainbowChunChunChang Level 1

                            To both George's who replied:

                             

                            I'm going to flag this thread as answered and award you the  points for it.

                             

                            It isn't optimal (Adobe, are you listening? ie code and steps for how to create the prerequisites etc. )

                             

                            but its good enough for this newbie.

                             

                            Thank you for your timely input!

                             

                            Rainbow Chang