Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Art & Graphic Design > InDesign CS Scripting Experience

InDesign CS Scripting Experience
Thread Tools
Exizl del Fuego
Junior Member
Join Date: Oct 2001
Location: Seattle, WA
Status: Offline
Reply With Quote
Aug 29, 2006, 07:13 PM
 
Does anyone have any experience scripting InDesign? I'm finding Adobe's Scripting Reference to be vague and cannot seem to post a new topic in Adobe's forums.

I'm trying to write a script (Javascript for CS1) that would change paragraph styles depending on the side of the page (Right-Hand Page or Left-Hand Page). I think I've got the business logic pretty well figured out, but I'm having trouble with the InDesign DOM details. Specifically, how do I compare and then set the appliedParagraphStyle. And how do I compare the page.side?

Below is my code:
Code:
var currentDocument = app.activeDocument; var currentPage; for (var i = 0; i < currentDocument.pages.length; i++) { currentPage = currentDocument.pages.item(i); currentParagraphs = currentPage.textFrames.item(0).paragraphs; var j; if (currentPage.side == rightHand) { for (j = 0; j < currentParagraphs.length; j++) { switch (currentParagraphs.item(i).appliedParagraphStyle) { case 'Style1 Left': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style1 Right'); break; case 'Style2 Left': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style2 Right'); break; case 'Style3 Left': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style3 Right'); break; case 'Style4 Left': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style4 Right'); break; case 'Style5 Left': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style5 Right'); break; default: var none = null; } } } else { for (j = 0; j < currentParagraphs.length; j++) { switch (currentParagraphs.item(i).appliedParagraphStyle) { case 'Style1 Right': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style1 Left'); break; case 'Style2 Right': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style2 Left'); break; case 'Style3 Right': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style3 Left'); break; case 'Style4 Right': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style4 Left'); break; case 'Style5 Right': currentParagraphs.item(i).appliedParagraphStyle = currentDocument.ParagraphStyles.item('Style5 Left'); break; default: var none = null; } } } }
     
Exizl del Fuego  (op)
Junior Member
Join Date: Oct 2001
Location: Seattle, WA
Status: Offline
Reply With Quote
Aug 29, 2006, 07:14 PM
 
Ooooh sorry guys, neither tabs nor spaces seem to come through appropriately.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:41 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,