Is it possible to set minimum and maximum font sizes in Acrobat PDF form fields?

I'm converting the paper form to an acrobat PDF form. I'm trying to make the text look as consistent as possible while also allowing it to fit into a set form field.

Is there a way to set the font size to be a maximum of a certain size while also allowing it reduced down to fit in each form field? I don't think it can be done directly in Acrobat, but how about using JavaScript?


Dan Dease


4 Answers

Voted Best Answer

Hi, this is what I tested:

1 text field

Properties...

Options

  • no Multiline, Chars Limit, Comb AND Allow Rich Text

Actions

  • OnFocus | Run JavaScript

add this code:

event.target.textSize = 0;
  • OnBlur | Run JavaScript

add this code:

var len = event.target.value.toString().length;
//console.println("LEN " + len);
if (len < 4) {
    event.target.textSize = 18;
}
else {
    event.target.textSize = 0;
}

What you will probably need to change to make it fit:

  1. len < 4: here 4 is the threshold number of chars below which you are switching from Automatic (just set with OnFocus) to Default font size;
  2. event.target.textSize = 18: change 18 to your preferred Default text size;

BTW: I hope you are not working with Rich Text or you can't follow above instructions and things may get more complicated.

Hope it helps.


By Ricardo Falegnami   

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf

page 446

However, I can't completely understand your problem.

JavaScript will run upon both

  1. a trigger event;
  2. page opening (which is actually an event too);

I don't think you will need JavaScript at page opening time because you would more appropriately set font size at design time.

You may need to increase/reduce font size if any other event happens: for example, if the end-user hovers the mouse over a text field, you may decide to change font size.

Another possible application may be an action. There, you may actually need JavaScript to set font size when filling in form fields for instance. So, you can differentiate font size according to which field is being filled in.

Hope it helps.


Ricardo Falegnami   

Thanks Ricardo.

Sorry for the vagueness of my original question. What I'm trying to do is fill out a simple table of rows and columns on an audit sheet. I have set the fields in this table to "auto" type size.

Unfortunately what I am getting is font sizes ranging from 8 point to 12 point. It's doing this because the fields contain calculated numbers that range from 3 to 6 spaces (ie, 10,000). As expected, the fonts are being reduced and increased based on the size of the input.

What I'm asking is there a way to set all fields two (let's say) 11 point and only have the fields that need to reduce do so?

Thanks!


Dan Dease   

Ricardo -

That works GREAT!

After tweaking the default text size per field column, I was able to get the form relatively consistent. Thanks so much for your help and expertise.

Dan


Dan Dease   


Please specify a reason: