Hello,
I need some help trouble shooting a script.
I am trying to flip the justification for all of a selected set of text frames. However, while most types of flipping work properly, the following does not
if(sel[i].story.textRange.justification == Justification.RIGHT){
sel[i].story.textRange.justification = Justification.LEFT;
}
I would expect the justification for items that are Justification.RIGHT to switch to Justification.LEFT, but they remain as Justification.RIGHT
It does not fail, it just does not work as expected.
What is odd is that it seems to work correctly for the three other types of justification I am flipping in the same script. See below for the full script.
Any ideas what is causing this?
try
{
// Check current document for textFrames.
if ( app.documents.length < 1 ) {
alert ( "open a document with text objects and select them." );
}
else {
docRef = app.activeDocument;
if ( docRef.textFrames.length < 1 ) {
alert ( "Select some text objects." );
}
//where text fames are selected swap the jusification
else {
sel = docRef.selection;
var sellen = sel.length;
for (var i=0;i<sellen ;i++)
{
if(sel[i].typename == "TextFrame"){
if(sel[i].story.textRange.justification == Justification.LEFT){
sel[i].story.textRange.justification = Justification.RIGHT;
}
else if(sel[i].story.textRange.justification == Justification.RIGHT){
sel[i].story.textRange.justification = Justification.LEFT;
}
else if(sel[i].story.textRange.justification == Justification.FULLJUSTIFYLASTLINELEFT){
sel[i].story.textRange.justification = Justification.FULLJUSTIFYLASTLINERIGHT;
}
else if(sel[i].story.textRange.justification == Justification.FULLJUSTIFYLASTLINERIGHT){
sel[i].story.textRange.justification = Justification.FULLJUSTIFYLASTLINELEFT;
}
}
}
}
}
}
catch (e){
alert("Script Failed!\n"+e);
}
Hi john,
thanks for responding.
Yes, I have tried printing out the justification to double check the settings.
I also just tried running the one line by hand. Works for switching a left justified text to Justification.RIGHT but not for switching a right justified text to Justification.LEFT
app.activeDocument.selection[0].story.textRange.justification = Justification.RIGHT;
Works on known left or center justified text
app.activeDocument.selection[0].story.textRange.justification = Justification.LEFT;
Fails on known right or center justified text
Possible bug in the implementation?
Give redraw a chance:
// Check current document for textFrames.
if ( app.documents.length < 1 ) {
alert ( "open a document with text objects and select them." );
}
else {
docRef = app.activeDocument;
if ( docRef.textFrames.length < 1 ) {
alert ( "Select some text objects." );
}
//where text fames are selected swap the jusification
else {
sel = docRef.selection;
var sellen = sel.length;
for (var i=0;i<sellen ;i++)
{
if(sel[i].typename == "TextFrame"){
if(sel[i].story.textRange.justification == Justification.LEFT){
sel[i].story.textRange.justification = Justification.RIGHT;
}
else if(sel[i].story.textRange.justification == Justification.RIGHT){
sel[i].story.textRange.justification = Justification.LEFT;
}
else if(sel[i].story.textRange.justification == Justification.FULLJUSTIFYLASTLINELEFT){
sel[i].story.textRange.justification = Justification.FULLJUSTIFYLASTLINERIGHT;
}
else if(sel[i].story.textRange.justification == Justification.FULLJUSTIFYLASTLINERIGHT){
sel[i].story.textRange.justification = Justification.FULLJUSTIFYLASTLINELEFT;
}
}
}
}
}
redraw()
I'm using
myTextFrame.resize(100.1,100.1);
myTextFrame.textRange.paragraphAttributes.justification = Justification.LEFT;
100.01 turns out to be not enough!
sorry for this
redraw(); doesn't work for me neither (CS5, OS X 10.8.2)
and I don't see justification property on textRange(?) - but
myTextFrame.story.textRange.justification = Justification.LEFT;
works as well. it seems that only resizing by X axis matters actually. indeed, frame can be resized back afterwards, it just takes to 'touch' the frame.
@CarlosCanto,
yes, I tried it now with CS5.1 on Win 7 and it doesn't work.
But I found the reason for that:
Your paragraphstyle is the normal paragraph style, right?
And you can change to all justifications, but not the LEFT one?
Make a new paragraph style with justification.FULLJUSTIFYLASTLINECENTER and apply it.
Now your script can change to all justifications, but not back to the FULLJUSTIFYLASTLINECENTER !
IMHO you can change to all, but in CS5 you can't go back to the justification, which is defined in the used paragraph style.
Is this so?
The solution should be: Use multiple paragraph styles in script
(or Adobe wishform --> bug or feature???)
North America
Europe, Middle East and Africa
Asia Pacific