Text flow create a delay when an overflow creates a new page, which prevents you from reading the page number, in error

Hi all!

I create a script to automatically generate a catalogue of photos; the idea is to prepare a master document with a text block in the master full of self flowing, then insert images with their legend by the script, let the system automatically creates the following pages when necessary, by a single stream of text.

My catalog is divided into sections, each represented by a different master spread; So I know what page I work when the script put there a picture just to link the current page in the master spread appropriate.

To simplify what I got most of my script here, using text instead of images:

/ * load a master document, only containing a block of empty text in the master spread, connected to the main text stream * /

var doc = app.open (new File("~/Desktop/mySampleDoc.indd"));

/ * I'm working on the story, thinking that every time that the textframe of first page will be full, we will create another block of text on the next page (automatically created) * /

var history = doc.pages [0] .textFrames [0] .parentStory;

/ * now, I put a few lines of text in history, pending the creation of a new on the first page will be complete * /

for (var i = 0; i < 100; i ++) {}

/ * This is the following line: * /.

.silence story.insertionPoints [-1] = "This is line n." + i + "\r";

/ * here, I want to know what page is the line just created (the error is generated here just in the creation of the new page + block of text) */

Thispage = story.insertionPoints [-1] .parentTextFrames [0].parentPage.documentOffset;

/ * and now I print the page number * /.

story.insertionPoints.item(-1).contents = "current page:"+ thispage + "\r"; ".

}

The big problem is: when the first block of text is full and overflow is generated, a new page with a new block of text from the main text flow (as the master spread) is generated. but it seems my script requests the page number before the new page with the new text block is born and an error is given.

It seems that the script goes too fast regarding the creation of the new page.

If I remove the line thispage = story.insertionPoints [-1] .parentTextFrames [0].parentPage.documentOffset; everything is ok.

I tried to introduce a delay up to 3 seconds with no effect.

I tried also to view or zoom in the request of page number, thought new page to force the system to wait for the page is truly born, also without effect (by the way, I wasn't able to view the page in adding the script of the text!).

Can someone help me?

A big thank you to everyone

Roberto

Have you tried using myDoc.recompose () before the application for compensation?

Tags: InDesign

Similar Questions

Maybe you are looking for