Article View: adobe.scripting.indesign
Article #768Re: extract items from a frame
From: Peter Kahrel
Date: Mon, 02 Mar 2009 18:15
Date: Mon, 02 Mar 2009 18:15
33 lines
2087 bytes
2087 bytes
Ola,
Robin is right: because you delete text frames as you go along, you mess up the collection of text frames. So you would have to start at the end of the document, working your way to the front.
But there are two more problems with your script: app.paste() doesn't take any arguments, so to feed it some coordinates is useless. What you need instead is app.pasteInPlace(). But that pastes frames on the first page of your document, which is no good. Finally, if you don't have to use copy/paste, don't: it often makes a pig of your document.
So a better approach is to work page by page, rather than story by story, so that you can duplicate frames easily on the correct page. But the duplicate method, when used on embedded frames, doesn't place them correctly, so it's easier to use this method:
myPage.textFrames.add (myFrame.properties);
which amounts to saying "on myPage, create a new text frame with the same properties as myFrame". These "same properties" include contents, size, position -- everything. An example to get you going is this (probably needs fine-tuning to your situation):
#target indesign
myPages = app.activeDocument.pages;
for (i = 0; i < myPages.length; i++)
{
myFrames = myPages[i].allPageItems;
for (j = myFrames.length-1; j > -1; j--)
{
myPages[i].textFrames.add (myFrames[j].properties);
myFrames[j].remove();
}
}
(This works in CS3/4, should also work in CS2.)
Peter
Technical Details
Message-ID:
<59b81716.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b81716.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,50e6c9aacf044ae5 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Peter Kahrel" <kahrel@kahrel.plus.com> Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: extract items from a frame Message-ID: <59b81716.1@webcrossing.la2eafNXanI> Date: Mon, 2 Mar 2009 10:15:26 -0800 References: <59b81716.-1@webcrossing.la2eafNXanI> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit