Anchor a text frame at insertion points
Hello
I am getting "object is invalid" error in the following code at line "tf = point.textFrames.add();"
Actually, I am looking for a unicode value "myUnicode" and storing its insertion points in an array.
Then at that point I wish to anchor a textframe (just after myUnicode char) with the contents the of "source" (1st para which is few chars only..like 4-5 chars). For the second match, add another textframe with second paragraph. "Source" has 17 paragraphs (each paragraph is few chars long only). "destination" has 17 "myUnicode" characters.
Any suggestions where am I doing wrong ?
Thanks
var myDoc = app.documents[0];
var myNum = [];
var iPoint = [];
var myUnicode = '\\x{002a}';
var myFrame = myDoc.textFrames.itemByName('source');
var myDestFrame = myDoc.textFrames.itemByName('destination');
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = myUnicode;
var myFound = myDestFrame.parentStory.findGrep();
for(i=0;i < myFound.length;i++){
iPoint.push(myFound[i].insertionPoints[0].index);
point = myFound[i].insertionPoints.item(iPoint[i]);
tf = point.textFrames.add();
tf.properties =
{
geometricBounds :[0,0,10,30],
strokewidth: 0,
fillColor : "None",
name : "test"+(i+1).toString(),
contents : txtFrame.itemByName('source').paragraphs[i].contents,
appliedObjectStyle: doc.objectStyles.item("rukus")
};
tf.anchoredObjectSettings.properties = {
anchoredPosition: AnchorPosition.ANCHORED,
anchorPoint : AnchorPoint.TOP_RIGHT_ANCHOR,
verticalReferencePoint : VerticallyRelativeTo.LINE_XHEIGHT
};
}
