6 Replies Latest reply on Nov 10, 2009 6:35 PM by CompTerra

    Popupmenu script affecting field properties

    CompTerra

      Hello,

       

      I have a working popup menu, when clicked it allows me to change the font size for any text fields found in a pdf.  I want to have the popup menu include the option to change the font not just the font size also including an alert stating the change. You will notice in the script the popupmenu is the way I want it. I have struggled with this as I am very new to it. I would also like to have the current font/size checkmarked (bmarked) in the menu so I know the current setting.  Thank you very much, I have already received very useful help here!

       

      fnt= app.popUpMenu(["Document Font Size","6","8","10","12","14","16"],["Document Font","sdfs"]);
      I = app.alert("You are about to change the Font size for all fields to: " + fnt, 2, 1);
      if (I != 2)
      {for(var i = 0; i < this.numFields; i++) {
      s = this.getNthFieldName(i);
      f = this.getField(s);
      f.textSize = fnt;}
      }
      else
      {
      }

        • 1. Re: Popupmenu script affecting field properties
          try67 MVP & Adobe Community Professional

          Like I replied to your other post about this matter, you need to use a global variable.

          Also, app.popUpMenu doesn't have the bMarked option. You need to use app.popUpMenuEx.

          1 person found this helpful
          • 2. Re: Popupmenu script affecting field properties
            CompTerra Level 1

            I understand what your saying about the bmarked however my issue is with the menu options being passed to the correct function and alert....you'll notice the font size selection gets passed down with an alert window then applied to the document (if I click okay on the alert window) ....how do I have the same thing occur with the font size options within the same popupmenu....I tried an if fnt = 6, 8, 10, 12 and so on but wasnt able to get that to work.

            • 3. Re: Popupmenu script affecting field properties
              try67 MVP & Adobe Community Professional

              I don't understand what is not working properly...

              1 person found this helpful
              • 4. Re: Popupmenu script affecting field properties
                CompTerra Level 1

                From the popup menu I select the font size....it works fine.

                 

                I want to do the same thing with the font...when I select a font I want it to be applied. With the current script it will only handle the font size...it needs to be re-written to handle the font as well as the font size.

                 

                Hope that helps..

                • 5. Re: Popupmenu script affecting field properties
                  MarkWalsh Level 4

                  Have you read the section in the Acrobat Javascript reference that describes the properties of a field? I haven't scripted fonts in acrobat before, but you have to make sure you get the correct syntax to set the font name. Examples from the reference:

                   

                  There are several pre-set values you can use for standard fonts:

                   

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

                  f.textFont = font.Helv;

                   

                  In Acrobat 5.0+, you can use an arbitrary font:

                  Set the font of "myField" to Viva-Regula:

                   

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

                  f.textFont = "Viva-Regular";

                   

                  But, you need to make sure you're using the correct string when setting an arbitrary font. Type this into the debugger console to determine the correct string to use for the font set for field 'Text1':

                   

                  this.getField("Text1").textFont

                  • 6. Re: Popupmenu script affecting field properties
                    CompTerra Level 1

                    I finally got it with the correct if statement......if I select a font size from the popup menu it will apply to the field property....if I select a font from the popup menu it will apply to the field property........