Saturday, June 02, 2007

 

More Edit Original

Let's replace that alert in the main function with some code that does something useful. First, let's just mimic what the Edit Original command does by simply opening the original document. To find that document, we use the itemLink property. So:
function editOriginalIDPage(sel) {
var myImpPage = getImpPage(sel);
if (myImpPage == null) return;
var myLink = myImpPage.itemLink;
app.open(File(myLink.filePath))
...
Well, that was easy. But what we really want to do is turn to the page that contains the imported page. Well, that information is available in the object's pageNumber property (which counts from 1 -- grrr):
function editOriginalIDPage(sel) {
var myImpPage = getImpPage(sel);
if (myImpPage == null) return;
var myPgNum = myImpPage.pageNumber;
var myLink = myImpPage.itemLink;
var newDoc = app.open(File(myLink.filePath))
app.activeWindow.activePage = newDoc.pages[myPgNum - 1];
app.activeWindow.zoom(ZoomOptions.fitPage);
...
And that does the job.

But of course, this was the easy part—so easy that one wonders why it isn't built into the application, but had it been, we wouldn't be having all this fun! Now the challenge is to try to integrate (a version of) our script into the Edit Original event handler. We don't want to take over the whole event because we only handle imported pages. We want to somehow pass control back to the application to handle all the other kinds of graphic.

At the moment, I'm going on blind faith that this must be possible. It might be a few days before I can get back to this because I'm in New York at the InDesign Conference this coming week and I have to finalize my preparations. Meanwhile, I've added a link to the current state of this script in the downloads list. [Life intervened and I've not yet added that link.]

Comments:
Hi

I was wondering if you ever needed to know the position (pagenumber) of a text frame in a document.

For example if I need to know the pagenumber in which a specific textframe is located. How would you do this?

The project consists in modifying ExportAllStories script (Included in the examples of Indesign).

The goal is to exportallstories to text files, but instead of using the StoryID as filename the script should use the pagenumber.



Regards
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?