Hi,
Is there a way to select textframes containing text that overflows and to resize the frame to stop the overflow?
What is the use of the postFix parameter in the areaText and pathText method ?
Regards,
Lionel Barth
first, I wrote below code. It is really you wanted, but I think you can reference it.
var slct = app.activeDocument.textFrames[0];
var plen = slct.paragraphs[0].length;
var hlen = slct.story.lines[0].length;
var hscale = paragraphs[0].scaling;
var step = 0.01;
while (plen != hlen) {
slct.paragraphs[0].scaling = [hscale,1];
hlen = slct4.story.lines[0].length;
hscale -= step;
}
We can detect overflows, comparing lines and paragraphs properties.
second,
We can make threaded textFrames, use baseFrame property. And normally, add to after baseFrames.
When we set postFix to true, areaText add to after baseFrame. See below.
var bf = app.activeDocument.selection[0];
var a=app.activeDocument.pathItems.rectangle (-100,100,100,100);
var b = app.activeDocument.textFrames.areaText(
a,
TextOrientation.HORIZONTAL,
baseFrame=bf ,
postFix=true
);
*upper frame is baseFrame.
var bf = app.activeDocument.selection[0];
var a=app.activeDocument.pathItems.rectangle (-100,100,100,100);
var b = app.activeDocument.textFrames.areaText(
a,
TextOrientation.HORIZONTAL,
baseFrame=bf ,
postFix=false
);
false mean preFix, like below image.
*upper frame is baseFrame.
Hi,
I am sorry, I've been so busy I cannot answer you sooner.
I have 2 problems with your solution.
1) some of my text areas have multi line text where all lines length are shorter than the paragraph length
2) I cannot find any information about a scaling property in the illustrator javascript reference. It seems I can read it but cannot write it.
Regards,
Lionel
OK Lionel, check below script.
//overflow control.
var counter = 0;
slct = app.activeDocument.selection[0];
cntsLength = getChars(slct);
visibleChar =getVisible(slct);
var vscale = 1.0;
stepNum = 0.02;
while (cntsLength != visibleChar) {
scalingWidth(slct, [vscale,1]);
visibleChar =getVisible(slct);
vscale = vscale-stepNum;
}
function getVisible(txObj){
var result=0;
for (var i=0;i<txObj.lines.length;i++){
result += txObj.lines[i].characters.length;
}
return result;
}
function getChars(txObj){
var result=0;
for (var i=0;i<txObj.paragraphs.length;i++){
result += txObj.paragraphs[i].characters.length;
}
return result;
}
function scalingWidth(txObj,wscl){
for (var i=0;i<txObj.paragraphs.length;i++){
txObj.paragraphs[i].scaling = wscl;
redraw();
}
}
This time we fit contents to textFrame, press contents width.
scaling property is an array. It contain horizontalScale and verticalScale.
scaling = [horisontalScale, verticalScale] (0 to 1)
If you want set to 100% width and height...
scaling = [1, 1];
Illustrators OMV sometimes do not written I really wanted to. So I try to check properties myself.
Ten wrote.
Hi,
The script has been written by Ten A ; I think you can make any change you need. If you wanted me to do the changes, I am very worry but I shall not have time to do it.
By the way I have found other scripts that can do the same, look at http://kelsocartography.com/scripts/ --> Fit Text Box to Text Content
Regards,
Lionel
North America
Europe, Middle East and Africa
Asia Pacific