Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Adding Spreads, Text Frames, and Linking/Threading them... HELP!?

$
0
0

Thank you for taking the time to few my post and trying to help me with this.

I'd like to point out and a beginner when it comes to script, so thank you in advance for your patience and understanding.

 

I'm working on a side project at work to try and help myself and other designers to improve workflow. The aim to to develop a script that will add 4 pages at a time (in spreads format / facing pages), with text frames that are linked/threaded.

I know that inDesign already has Smart Text Reflow, but unfortunately due to how our templates are set up, this doesn't work the way it needs to. I wish changing our templates was an option, but it isn't.

 

Below you'll find an example of how we work...

 

Screen shot 2014-05-14 at 11.46.31.png

 

As you can see, our templates are already set up in printers spreads with the inside pages containing a text frame with the inside front frame (1) being linked/threaded to the inside back frame (2).

 

So this is the starting point...

 

I've worked out that I can add new spreads using the following:

 

doc = app.activeDocument
mySpread=doc.spreads.add();

 

The trouble I'm having at the moment is adding a text frame to each of the individual page within that spread.

 

I can add a text frame by telling it which page to add it to...

 

myDocument = app.activeDocument


var myPage=myDocument.spreads.item(-1).pages.item(-1);
var myPages= myDocument.spreads.add(LocationOptions.atEnd);


//Assumes that the active document has a master page named "B-Master"


//and at least three pages--page 3 is pages.item(2) because JavaScript arrays are zero-based.


//app.activeDocument.pages.item(4)


//app.activeDocument.masterSpreads.item("B-Master");


//app.activeDocument.pages.item(5)


//app.activeDocument.masterSpreads.item("B-Master");






//Create a text frame on the current page.


var myTextFrame = app.activeDocument.pages.item(4).textFrames.add();
myTextFrame.geometricBounds = myGetBounds(myDocument, myPage);
//myTextFrame.geometricBounds = [307, 410, 28.346, 28.346];


function myGetBounds(myDocument, myPage){


var myPageWidth = myDocument.documentPreferences.pageWidth;


var myPageHeight = myDocument.documentPreferences.pageHeight


if(myPage.side == PageSideOptions.leftHand){


var myX2 = myPage.marginPreferences.left;


var myX1 = myPage.marginPreferences.right;


}


else{


var myX1 = myPage.marginPreferences.left;


var myX2 = myPage.marginPreferences.right;


}


var myY1 = myPage.marginPreferences.top;


var myX2 = myPageWidth - myX2;


var myY2 = myPageHeight - myPage.marginPreferences.bottom;


return [myY1, myX1, myY2, myX2];


}

 

This adds to text frame to the left page of the spread. I'm unsure how to add it to the right page of the spread.

Alongside this, I don't want to have to tell it which pages, for when the script is run again, it will simply add them to the same pages and not the new ones.

So I'm assuming a loop might need to be used?

 

After looking around I did find the following script that works, but not in spreads and I can't adjust it to work with spreads...

 

// add a page at the end of the current document,
// place a text frame on it, and link the text frame




doc = app.activeDocument
np = doc.pages.add();
marg = np.marginPreferences;
gb = [marg.top, marg.left,
  doc.documentPreferences.pageHeight - marg.bottom,  doc.documentPreferences.pageWidth - marg.right];
oldRuler = doc.viewPreferences.rulerOrigin
doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
with( doc.pages[-1].textFrames.add() )  {  geometricBounds = gb;  previousTextFrame = doc.pages[-2].textFrames[0];  }
doc.viewPreferences.rulerOrigin = oldRuler




myItems = app.activeWindow.activeSpread.pageItems;

 

 

I would love to be able to use this but for spreads instead.

 

The trouble which this is it links/threads the text frame with the previous page, but as I mentioned before, our templates are set up in Printers Spreads, so the threading needs to be as shown below:

 

Screen shot 2014-05-14 at 11.51.05.png

 

I hope this makes sense. Please feel free to ask any questions you want. I hope together we can develop this script to how I need it to be.

 

Scorpio


Viewing all articles
Browse latest Browse all 15932


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>