0

After I imported XML-Data into an InDesign document I see that red plus symbol at the textframe at the end of the first page.

How can I insert/move that content on next page(s) with scripting?

Kody
  • 1,154
  • 3
  • 14
  • 31

5 Answers5

3

This script should do what you want. :)

var myDoc = app.activeDocument;
var myFrames = myDoc.textFrames;
while (myFrames[0].overflows === true) {
    var myNewPage = myDoc.pages.add();
    var myMargin = myNewPage.marginPreferences;
    var myBounds = [myMargin.top, myMargin.left, myDoc.documentPreferences.pageHeight - myMargin.bottom, myDoc.documentPreferences.pageWidth - myMargin.right];
    var myOldRuler = myDoc.viewPreferences.rulerOrigin;
    myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    with(myDoc.pages[-1].textFrames.add()) {
        geometricBounds = myBounds;
        previousTextFrame = myDoc.pages[-2].textFrames[0];
        }
    myDoc.viewPreferences.rulerOrigin = myOldRuler;
    }
Brett
  • 31
  • 3
  • 1
    @Brett: Nice one! Works and should be the accepted answer. – allcaps Mar 20 '14 at 19:01
  • 1
    I tried it again. It added just pages over and over again. I had to stop the scrip after 800 pages. I don't have that much content. – Kody Mar 21 '14 at 09:32
  • Sorry to hear it didn't work Kody. I am interested by the error, it sounds as if the code is seeing your textFrame in a permanent overflow state. When you look at the InDesign file do you have a red plus sign in the bottom right corner of the textFrame? – Brett Apr 01 '14 at 23:04
  • Just out of interest, how many textFrames are on the page? And, are you sure you're pointing to the correct one? If there is confusion about the textFrame you could try using the script label instead of myFrames[0], it would now read myFrames.item("script label name"). If this doesn't work, let me know. – Brett Apr 01 '14 at 23:10
2

The TextFrame object has a property overflows: Bool, readonly. If true, the story has overset text.

The TextFrame object has also a property nextTextFrame: r/w The next text frame in the thread. Can return: TextFrame or TextPath. Can also accept: NothingEnum enumerator.

http://jongware.mit.edu/idcs6js/pc_TextFrame.html

allcaps
  • 10,945
  • 1
  • 33
  • 54
  • Ok thank's for your information. But how can solve my problem with that? – Kody Mar 19 '14 at 16:22
  • If `app.activeDocument.textFrames[0].overflows` than create page, create frame, link frames with `nextTextFrame`. Or link the frames like @Brett did with `previousTextFrame`. – allcaps Mar 20 '14 at 19:10
0

not sure you need scripting... if the document is set up as a template simply click the plus sign and "capture" the contents. then move to the next page and click where you want the text to reflow to. adjust the text boxes as needed to suit.

Phlume
  • 3,075
  • 2
  • 19
  • 38
  • I already know this can be done manually, but it definitely has to done with **scripting**. – Kody Feb 26 '14 at 09:00
0

For the non-scripting solution to flowing overset text frames, after adding a new page, hold down shift before clicking. This will cause the text to autoflow on as many pages as it takes until there is no longer an overset text frame.

Tim
  • 1
0

From CS4, we can enable the "Smart Text Reflow" to automatically flow text to the available content. It will insert the pages automatically.

Edit Menu \ Preferences \ Type \ Smart Text Reflow

Also, it comes with "Delete Empty Pages", so when the content goes less, then it will automatically remove the empty pages accordingly.

Shiv
  • 1,211
  • 4
  • 14
  • 24