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

Rectangle size trimming

whatever
Registered: Aug 23 2007
Posts: 21

Is there a way to adjust the rectangle size of a textField to fit the actual content?
 
I need to bordered a textfield with variable content using a autoadjust size border.
 
Any hint will be highly appreciated.
 
Our standard version is acrobat reader 7.0

My Product Information:
Acrobat Standard 6.0.0, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
This Javascript makes a text field multiline and triple its height. (Doc Level Javascript)

var f = this.getField("myText");
var aRect = f.rect;// get bounding rectangle
f.multiline = true;// make it multiline
var height = aRect[1]-aRect[3];// calculate height
aRect[3] -= 2* height;// triple the height of the text field
f.rect = aRect;// and make it so

Here's another option:

If the text field is filled up by the user, allow additional text by setting the field to scroll.

if ( event.fieldFull )
{
app.alert("You've filled the given space with text,"
+ " and as a result, you've lost some text. I'll set the field to"
+ " scroll horizontally, and paste in the rest of your"
+ " missing text.");
this.resetForm([event.target.name]); // reset field to lose focus
event.target.doNotScroll = false;// make changes
if ( event.target.richText )
event.richChange = event.richChangeEx
else
event.change = event.changeEx;
}

Hope this helps.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

whatever
Registered: Aug 23 2007
Posts: 21
Thanks Eugene for your answer.

I've wrote down your answers 'cause I've found them useful, however what I need is a little different.

What i need is a way to calculate the text length measured in pixels i order to define the rectangle dimensions.

Let me explain with more detail:
1) I create the PDF with iText.
2) The Pdf file already contains a text field since it is created, let's call it myField.
3) The Pdf file also has an injected javascript at "will print" which assigns the value to the field: "myField.value='...';"

So the variable content fieldText is refered to the user-agent who assigns the content.

From the javascript side the text field content appears as fixed length.

thanks again Eugene
pddesigner
Registered: Jul 9 2006
Posts: 858
Hi whatever,
The situation you've described is beyond my expertise. Please re-post this question here or on the user forum.

Sorry I couldn't help.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.