Copy link to clipboard
Copied
There have been a few similar topics recently, so I installed the Arabic version of Illustrator to investigate these items.
The conclusion is as follows:
/**
* @File An example of ExtendScript to set paragraph direction and character direction
* @version 1.0.0
* @author sttk3.com
*/
(function() {
var doc = app.documents[0] ;
var sel = doc.selection[0] ;
/* Paragraph Direction
ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION
ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION
*/
...
Copy link to clipboard
Copied
I'm not sure if this is what you're looking for, but you can try it.
activeDocument.selection[0].textRange.paragraphDirection = ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION
and
activeDocument.selection[0].textRange.paragraphDirection = ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION
Copy link to clipboard
Copied
Hi @Sergey Osokin
Thanks for your reply.
I need to fetch which direction currently the textframe content showing using extendscript and also how to apply these two options using extendscript.
Please check the below two screenshot
right-to-left Character Direction
left-to-right Character Direction
Copy link to clipboard
Copied
Hi @Sergey Osokin
For paragraphDirection ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION its working fine. But ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION not working in illustratror. Please help on this.
Thanks in advance
Copy link to clipboard
Copied
I don't know much about character direction in Illustrator, and I don't have a choice of directions in the Character panel menu like in your screenshots.
Copy link to clipboard
Copied
@Sergey Osokin, where did you get that handy 'js console' plugin?
Copy link to clipboard
Copied
Free extension by Russian developer Marat Shagiev. Marat is also the author of various scripts and other extensions, mainly for the printing industry.
Copy link to clipboard
Copied
Awesome! I looked all
over GitHub to try and find that. Thanks for the link!
Copy link to clipboard
Copied
Thanks for reply
@Sergey Osokin I'm using Arabic version of illustrator. Normal version of illustartor RIGHT_TO_LEFT_DIRECTION working fine. But in Arabic version of illustrator not working.
Note: In Arabic Version of illustrator there is option for paragraph direction and character directions in paragraph and character menu.
Copy link to clipboard
Copied
Knowing how many problems there are in ExtendScript that Adobe doesn't care about, I'm not surprised that Adobe engineers didn't consider the functionality of the Arabic version of Illustrator for ExtendScript either.
Copy link to clipboard
Copied
There have been a few similar topics recently, so I installed the Arabic version of Illustrator to investigate these items.
The conclusion is as follows:
/**
* @File An example of ExtendScript to set paragraph direction and character direction
* @version 1.0.0
* @author sttk3.com
*/
(function() {
var doc = app.documents[0] ;
var sel = doc.selection[0] ;
/* Paragraph Direction
ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION
ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION
*/
setParagraphDirection(sel.textRange, ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION) ;
/* Character Direction
DirOverrideType.DEFAULT_DIRECTION
DirOverrideType.RIGHT_TO_LEFT_DIRECTION
DirOverrideType.LEFT_TO_RIGHT_DIRECTION
*/
sel.textRange.dirOverride = DirOverrideType.RIGHT_TO_LEFT_DIRECTION ;
})() ;
/**
* Set the paragraph direction. This will succeed even if the specified property is the same as [Normal Paragraph Style]
* @Param {TextRange} range target text range
* @Param {ParagraphDirectionType} dstDirection destination paragraph direction
*/
function setParagraphDirection(range, dstDirection) {
var appliedParagraphStyle = range.paragraphStyles[0] ;
var styleDirection = appliedParagraphStyle.paragraphDirection ;
if(styleDirection === dstDirection) {
var swapMap = {
'ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION': ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION,
'ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION': ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION
} ;
appliedParagraphStyle.paragraphDirection = swapMap[dstDirection.toString()] ;
range.paragraphDirection = dstDirection ;
appliedParagraphStyle.paragraphDirection = styleDirection ;
} else {
range.paragraphDirection = dstDirection ;
}
}
Check the AppleScript scripting dictionary and you will find the properties that can be controlled.
Copy link to clipboard
Copied
Thanks @sttk3
Character Direction working properly.
In Illustrator Arabic Version ParagraphDirectionType.LEFT_TO_RIGHT_DIRECTION working properly. But ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION - ParagraphDirectionType.DEFAULT_DIRECTION not wroking as expected. Please help on this.
Note: Other than Arabic version both ParagraphDirectionType working properly.
Thanks in advance
Copy link to clipboard
Copied
ParagraphDirectionType.DEFAULT_DIRECTION should not work because the property does not exist.
As for ParagraphDirectionType.RIGHT_TO_LEFT_DIRECTION, the result is caused by Illustrator's specification that it is ignored if we set the same property as the paragraph style being applied.
The above script has a workaround function setParagraphDirection to avoid this. Instead of just setting the paragraphDirection property, try specifying it via setParagraphDirection.