Hi @Laubender ,Thanks for your reply, here is my try, i succeded in first part as you guide me, script tooks all document story tables and put them in new frame but i didnt figure how to Anchor them! , please help and thanks in advance
//Convert All Story Tables to Anchored Tables
var myDoc = app.documents[0];
var allTablesStory = myDoc.stories.everyItem().tables.everyItem().getElements()
function ConvertTables(){
//Add New Frame
var newTextFrame = myDoc.textFrames.add({geometricBounds:[0,0,100,100]});
//Loop in TextFrame Story Tables
for(i=0;i<allTablesStory.length;i++){
allTablesStory[i].storyOffset.parentStory.characters[allTablesStory[i].storyOffset.index].move
(
LocationOptions.BEFORE , newTextFrame.insertionPoints[0]
);
}
}
//Undo mode Entire Script
app.doScript(ConvertTables, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Convert Story Tables to Anchored Tables");
and just wondering? does making new frame is a must? i mean i cant convert them in their normal position in the original frame? and thanks you again
Hi M.Hasanain,
there is no "conversion" process. A table is a table. Reperesented by a single character in a story.
Every text, also every single character, must be part of a story and this story requires a text container ( tables do not render on text paths, only in text frames ) . So in case of a table it could be a story with only one character in a single text frame; nothing else. That text frame could be anchored or not. The table is not anchored. The text frame is.
To anchor an unanchored text frame you need to know the insertion point where the text frame should be anchored. If that is given and the insertion point is stored into a variable, anchoring works like this:
myNewTextFrame.anchoredObjectSettings.insertAnchoredObject
(
myTargetInsertionPoint ,
AnchorPosition.ANCHORED
);
Well, this might look strange at first glance ( on second one as well! ) that the method is not with an insertion point, but with the object you want to anchor; but that's the way it was contructed by the developers of InDesign in InDesign version 7.5 and also above.
Note: The second argument of the method, the anchor position, could be one of three options:
AnchorPosition.INLINE_POSITION
AnchorPosition.ABOVE_LINE
AnchorPosition.ANCHORED
Details:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchorPosition.html
Regards,
Uwe Laubender
( ACP )