-
1. Re: CS3 JS Double Page Spread
Marc Autret Apr 21, 2010 3:52 AM (in response to John.Kordas)InDesign assumes that a pageItem ‘belongs’ to a page if the geometric bounds of the page contains the center point of the pageItem bounding box. So you can have a pageitem located on page N that overlaps some other pages in the same spread. Actually the most relevant geometric container is the spread. To know if a page is really blank, you can traverse the parent spread page items collection and check if the bounds of one object intersects your target page.
Try this:
Page.prototype.hasPageItems = function() { var sprd, pItems, b, ib; // check if the page contains a direct page item if( this.pageItems.length > 0 ) return true; // check if the page intersects a spread page item if( (sprd=this.parent).pageItems.length > 0 ) { b = this.bounds; pItems = sprd.pageItems; for( i=pItems.length-1 ; i>=0 ; --i ) { ib = pItems[i].geometricBounds; if( b[0]<=ib[2] && ib[0]<=b[2] && b[1]<=ib[3] && ib[1]<=b[3] ) return true; } } return false; } // sample test var doc = app.activeDocument; alert( doc.pages[2].hasPageItems() );@+
Marc
- - -
-
2. Re: CS3 JS Double Page Spread
Laubender Apr 21, 2010 6:05 AM (in response to Marc Autret)Hello Marc,
your function does not work if the zero point is defined by page or by spine. If the zero point is defined by spread it is working very well.
(InDesign CS4 6.0.4 on Mac OS X 10.5.8)Uwe
-
3. Re: CS3 JS Double Page Spread
Marc Autret Apr 21, 2010 6:33 AM (in response to Laubender)That's right. I just give a snippet for the main routine. In a complete script we often need to deal with user specific settings.
I usually write a backup/restore method to set the preferences as needed during the script execution. Something like:
// backup the settings
var vPrefs = doc.viewPreferences;
var bkpOrigin = vPrefs.rulerOrigin;
// set the origin as needed
vPrefs.rulerOrigin = RulerOrigin.spreadOrigin;
/* THE SCRIPT PROCESS HERE */
// restore the settings
vPrefs.rulerOrigin = bkpOrigin;
@+
Marc
-
4. Re: CS3 JS Double Page Spread
John.Kordas Apr 21, 2010 10:56 PM (in response to John.Kordas)Thanks Marc,
This is very interesting. I have a slight problem as the book I'm testing has full page bleed elements so even pages that do not have elements but have one that is bleeding off to the side come up as true. The bleed is only 5mm but it's enough to pick it up.
Any suggestions?
Cheers, John.
-
5. Re: CS3 JS Double Page Spread
John.Kordas Apr 28, 2010 4:07 PM (in response to John.Kordas)Thanks Marc,
I was finding that pages that had bleed on one side of the spread would still be picked up and exported. To get around this all double page spreads are placed on the left had page so to check this I added.
myPageName%2 == 1
Then I also checked there was an item on the spread using
myDocument.pages[myPageName-1].parent.pageItems.length >0
Finally I check that the item on the spread is wider than one page.
myDocument.pages[myPageName-1].parent.pageItems[0].geometricBounds[3] > (app.activeDocument.documentPreferences.pageWidth + 5)
All together:
if(myPageName%2 == 1 && myDocument.pages[myPageName-1].parent.pageItems.length >0 && myDocument.pages[myPageName-1].parent.pageItems[0].geometricBounds[3] > (app.activeDocument.documentPreferences.pageWidth + 5)){
I was trying to solve this at a page level and when I broke down your code the answer was to work at the spread level instead.
Thanks for your example and I also suggest people check out your website.
Cheers John.



