Skip to main content
New Participant
October 19, 2019
Answered

Setting a max text size, but shrinks when needed

  • October 19, 2019
  • 1 reply
  • 2509 views

Hello,

 

I'm building a simple form that has a few text boxes. I need the boxes to have a max text font size of 6. However, I need that size to shrink if the user inputs more text than the box size. I don't have room for wrapping or multiple lines. I found an answer on this form via google that told me to do the following

 

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;
}

 

Ref: https://answers.acrobatusers.com/Is-it-possible-to-set-minimum-and-maximum-font-sizes-in-Acrobat-PDF-form-fields-q110082.aspx

 

However, when I attempt to use this code (but with text size set to 6) it will work the first time text is entered. However, If I erase some text and try to put anything else in, the text will go bigger than 6 point. It goes back to "auto" text size. The JavaScript only seems to work one time. I'm pretty new to using JavaScripts. What am I doing wrong? Any help is appreciated.

 

I'm using Adobe Acrobat Pro DC

 

    This topic has been closed for replies.
    Correct answer JR Boulay

    Hi

     

    Set the field height to 0.32 or 0.33 centimetres, so the auto-sized text begins with a size of (about) 6 pt.

    😉

     

    1 reply

    JR Boulay
    JR BoulayCorrect answer
    Adobe Expert
    October 19, 2019

    Hi

     

    Set the field height to 0.32 or 0.33 centimetres, so the auto-sized text begins with a size of (about) 6 pt.

    😉

     

    Acrobate du PDF, InDesigner et Photoshopographe
    PNWB2Author
    New Participant
    October 22, 2019

    Well, that was an easy fix. Thank you!