Releasing All Anchor objects/text frames
Dear All,
This is my 1st question on AC (Adobe Community), so i will explain what i need here in details and excuse me about my few or even none Experienced in Coding specially in Javascript.
I have a book with many INDD files, these files has a lot of images and objects and text frames are anchored to main text box.
i was searched on AC for way to release all my anchored object and text frames from main text frame. so i found script way.
i found one its name "ReleaseAnyAnchor" and created by "Dave Saunders" to release anchored object (Graphic/text/else) But one by one. and this will take too much time from me to release all the objects on the book. (the code of the Script is below)
//DESCRIPTION: Release Inline & Anchored Items
//Written by Dave Saunders, released on indesignsecrets.com
(function() {
if (app.documents.length > 0 && // must be a document open
app.selection.length == 1 && // selection must be of single item
app.selection[0].parent instanceof Character) { // selection must be anchored
if (parseFloat(app.version) < 6) {
releaseMe(app.selection[0]);
} else {
app.doScript(releaseMe, undefined, app.selection[0], UndoModes.entireScript, "Release Any Anchor");
}
} else {
alert("Please select an inline item.");
}
function releaseMe(myPI) {
var yePage = findPage(myPI);
var startBounds = myPI.geometricBounds;
myPI.anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;
myPI.anchoredObjectSettings.releaseAnchoredObject();
if (yePage != null) {
myPI.move(yePage);
}
myPI.move([startBounds[1], startBounds[0]]);
}
function findPage(theObj) {
if (theObj.hasOwnProperty("baseline")) {
theObj = theObj.parentTextFrames[0];
}
while (theObj != null) {
if (theObj.hasOwnProperty("parentPage")) return theObj.parentPage;
var whatIsIt = theObj.constructor;
switch (whatIsIt) {
case Page : return theObj;
case Character : theObj = theObj.parentTextFrames[0]; break;
case Cell : theObj = theObj.insertionPoints[0].parentTextFrames[0]; break;
case Note : ; case Footnote : theObj = theObj.storyOffset; break;
case Application : return null;
}
if (theObj == null) return null;
theObj = theObj.parent;
}
return theObj
} // end findPage
}());
also i found another script that release all the graphics objects but not the Text frame objects. (i get it from AC but i don't remember exactly from where.)
if(app.documents.length!=0) {
var ad = app.activeDocument;
var pgit = ad.pageItems;
var pgitlg = pgit.length;
var objprocessed = 0;
if(pgitlg !=0)
{
for(i=0; i<pgitlg; i++)
{
if(pgit.getElements()[0].constructor.name == "TextFrame")
{
var tfg = pgit.allGraphics;
var tfglg = tfg.length;
for(j=0; j<tfglg; j++)
{
var rec = tfg
.parent; rec.anchoredObjectSettings.releaseAnchoredObject();
}
}
}
}
}
all the codes are working fine for me, but i need to try to merge or make a new code [as i mentioned that i don't have experiences in JS so i don't know how to compile a new code that make 2 steps of the 2 codes.]
my Request is, Could you please help me to make this new code, or merge them or compile a new code in new file.
i saw this topic Releasing Anchored objects and want to make a new script.
Please try to help me ASAP as i need this script to release all my anchored object to start work on the file.
I need the code to work on any version of INDESIGN.
Thanks guys, waiting you.
Amr
