• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Using Action Wizard to change font in Combo Box

Explorer ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

Acrobat Pro DC on a MAC running OS X 10.11.6

I have a form that is mainly set up in Indesign (it works for us - I know others prefer to set forms up purely in Acrobat).

I have a script I can run via Action Wizard (execute a javascript) to change the font in all the text form fields. But being a script-novice I can't figure out how to create a similar script which will change the font used by Combo Boxes (created in Indesign). Can this be done by a script?

I know I can do it manually via Properties but if anyone can give me a pointer to figure out how to do it with a script that would be amazing!

Thank you

TOPICS
Acrobat SDK and JavaScript

Views

1.5K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 20, 2016 Sep 20, 2016

The script can be changed to:

for (var i = 0; i < numFields; i++) {

    var f = getField(getNthFieldName(i));

    if (f.type === "text" || f.type === "combobox") {

        f.textFont = "Arial";

        f.textSize = "10";

    }

}

But now I have to ask, what are your reasons for using Arial instead of Helvetica?

Likes

Translate

Translate
LEGEND ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

Yes, it can be done with the same script you're using for text fields. If you post the script, I can suggest a change you can make.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

Thank you - very appreciated!

I'm using:

/* Convert all text fields to 10pt Arial */

for (var i = 0; i < this.numFields; i++) {

    var fname = this.getNthFieldName(i);

    if (this.getField(fname).type == "text") {

        this.getField(fname).textFont = "Arial";

  this.getField(fname).textSize = "10";

}

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

The script can be changed to:

for (var i = 0; i < numFields; i++) {

    var f = getField(getNthFieldName(i));

    if (f.type === "text" || f.type === "combobox") {

        f.textFont = "Arial";

        f.textSize = "10";

    }

}

But now I have to ask, what are your reasons for using Arial instead of Helvetica?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

You star! Thank you so much - that saves me a world of pain! Arial is just the customer preference! No other reason.

Also - it could be system glitch but quite often when opened in Reader it looks more like Times or Courier than Helvetica?

Again thank you so much - I kept trying variations but my scripting knowledge is just too non-existent.

Thank you thank you!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2016 Sep 20, 2016

Copy link to clipboard

Copied

When Helvetica is used in a form field, Acrobat/Reader actually use a private version of Arial instead. This type of substitution is allowed PDF spec. The problem when you use Arial instead of Helvetica is that the entire font is included in the file, which merely increases the file size unnecessarily. The base-14 fonts (Times, Helvetica, Courier, Symbol, and their variants) or suitable replacements are guaranteed to be available in a compliant PDF viewer, so there's no need to include their font data in the document. The problem is, once you've specified Arial, Acrobat doesn't get rid of the now unused font data if you switch to using Helvetica and do a Save As, so you have to start with a fresh file, which fortunately isn't difficult if you're creating the fields in InDesign.

If you happen to have a screen shot of Helvetica looking like Times or Courier, I'd be interested in seeing that. I know that Preview can make the fonts look different than they should, but I've never seen this with Acrobat or Reader.

Also, since you're dealing with fields created when exporting from InDesign, here's a better script for you to use:

for (var i = 0; i < numFields; i++) {

    var f = getField(getNthFieldName(i));

    if (f) {

        if (f.type === "text" || f.type === "combobox") {

            f.textFont = "Arial";

            f.textSize = "10";

        }

    } else {

        app.alert("The field " + getNthFieldName(i) + " does not exist.\r\rBad InDesign!", 3);

    }

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 21, 2016 Sep 21, 2016

Copy link to clipboard

Copied

Size isn't really an issue - it's still less than 400k for the document.

If I do a standard export to interactive form Indesign, Open the PDF, go to prepare form and check the field properties. It selects Times Roman as the default font which the customer definitely doesn't want.

It may be something on the set-up of the mac I'm working on but we've agree to use Arial as default for any of these kind of documents.

thanks!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

LATEST

Hello,

I see this is a fairly old post, but would someone tell me how to use Acrobat XI Action Wizard javascripting to change the default squares to checks in all checkbox fields? Text fields worked right away, but no joy with the checkboxes... 😕

Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 05, 2017 Jul 05, 2017

Copy link to clipboard

Copied

Dear George_Johnson the code you provide is not working correctly, i test it in the console and it shows the message that there is an error.

SyntaxError: syntax error

1:Console:Exec

undefined

Could you please let me know the best way to run this script or check it at your side again?

waiting for the reply as I have the same issue here.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2017 Jul 05, 2017

Copy link to clipboard

Copied

The code above is fine. Did you edit it in any way?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

I tried now correctly and it's working fine.

the problem was from my side.

thanks for your help.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 01, 2018 Nov 01, 2018

Copy link to clipboard

Copied

This script is super helpful! Thanks for sharing!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines