|
|
InDesign CS Scripting Experience
|
|
|
|
Junior Member
Join Date: Oct 2001
Location: Seattle, WA
Status:
Offline
|
|
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;
}
}
}
}
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2001
Location: Seattle, WA
Status:
Offline
|
|
Ooooh sorry guys, neither tabs nor spaces seem to come through appropriately.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|