These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

/MaxLen for text fields does nothing?

hogwell
Registered: Apr 16 2011
Posts: 6
Answered

I am trying to generate PDF AcroForm code for a simple text input field and applying the /MaxLen tag to limit the number of entered charcters, e.g.
 
/MaxLen 5
 
However, Acrobat Reader lets me type in this field beyond 5 characters anyway.
 
The PDF reference manual implies that this should limit the user entry to the given length.
 
What does this tag do?
Does it just truncate the entry after Submit is pushed?
Could I be using /MaxLen incorrectly?
 
Thanks for any advice.
 

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The /MaxLen parameter is an entry in the COS field dictionary for a text field. It is the same as the "Fields.charLimit" property in JavaScript and the "Limit of" option on the Text Field Properties Dialog. In fact the Field Properties dialog is a good place to learn about how this parameter is used.

I take it you are write an application to generate a PDF, and that you have a PDF library of some kind? If you are not using a PDF Library you will need to become an expert on the internal PDF format.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hogwell
Registered: Apr 16 2011
Posts: 6
Thanks for your response, Thom.

Yes, I am troubleshooting / maintaining an application that generates pdf 1.4 output.

And I'm stumped on this one.
From everything I've read (e.g. the PDF Reference Manual), adding the /Maxlen entry for an AcroForm text field should limit how many characters the user can enter in the form field.

Here is more detail on my pdf code for the text field:

11 0 obj
<<
/Type /Annot
/Subtype /Widget
/Rect [ 40 726 179 739 ]
/T (FillText1)
/FT /Tx
/DA (/TiRo 10 Tf 0 g)
/Maxlen 5
/F 4
/StructParent 1
>>
endobj

Very simple.
However, running this form in Acrobat Reader 9 allows me to type more than 5 characters, in fact the length seems unlimited and scrolls horizontally, ignoring /Maxlen.
(Other than that, the form works fine.)

Note that for this field, there are no field flags (/Ff), but it is a plain text entry field and doesn't need any flags. Do I need to add /Ff 0 anyway perhaps? Do I have to supply the NoScroll flag to enable /Maxlen to work?

I suppose I could write some javascript to capture keystrokes and do the counting myself, but it doesn't seem like that should be necessary.

Thanks for any advice - at this point I'd almost think it is a bug in Acrobat Reader 9, but I can't imagine that - this would be a pretty major bug!


George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Accepted Answer
Your example shows Maxlen, not MaxLen.
hogwell
Registered: Apr 16 2011
Posts: 6
Thanks, George
That was it!
(I knew it had to be something SiMPle...)


thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Details, details!! Good catch George!

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script