How to change the alignment of text using javascript?
Hi,
I need to change the alignment of text to center.
for (var i = 1 ; i <= graphNumberOfLines + 1; i++)
{
var ii=i;
ii= doc.textFrames.add(); //adding text
ii.textRange.characterAttributes.size = 8; //character size for text
ii.textRange.characterAttributes.textFont = app.textFonts.getByName("Times-Roman");
ii.textRange.StyleRunAlignmentType = "Center";
ii.top = firstPoint[1]+yGraphInc; //x coordinate for the new value
ii.left = firstPoint[0]+xGraphInc; //y coordinate for the new value
finalContent=Number(graphFirstValue)+graphIncValue;
finalContent=finalContent.toString();
var finalContentcheck=Number(finalContent.indexOf("-"));
if(finalContentcheck>=0){
finalContent=finalContent.replace(/-/g,"–");
}
ii.contents=(finalContent); //content for the text frame
xGraphInc=(xGraphDiff/graphNumberOfLines)*i; //incrementing the x coordinate
yGraphInc=(yGraphDiff/graphNumberOfLines)*i; //incrementing the y coordinate
if(graphValues[1]>=0){
graphIncValue=graphIncValue+graphIncrement; //incrementing the content
}else{
graphIncValue=graphIncValue-graphIncrement; //incrementing the content
}
}
This is how I am writing in the document. I need to align just after writing.
Thanks in advance.
