Tuesday, February 06, 2007

 

Selective Paragraph Style Properties Import

I'm working on two very similar posters. They are 30 x45 inches with a highly elaborate background image. So, for proofing purposes, I created a couple of documents that had the text of the posters on regular letter-sized pages. Each of these documents ran to 16 pages and each is a single very long table.

Everything started out with the same style names and definitions, but the text on one side wouldn't fit at that size, so I had to make it smaller.

So, here I am with two posters using the same styles but the text needs to be at a different size in one of them. I can't just import the styles from the proof document because the colors are wrong. All I want to do is transfer the font size and leading from the styles in the proof document to the corresponding styles in the poster.

Given that this is a one-shot script, I decided to simply open both documents with the poster at the back and the proof in front and then transfer the properties from the front document to the back. Here's the script:
//DESCRIPTION: Transfer font size and leading from styles in doc[0] to styles in doc[1]

myBackDoc = app.documents[1];
myFrontDoc = app.documents[0];
backStyles = myBackDoc.paragraphStyles.everyItem().name;
for (j = backStyles.length - 1; j > 0; j--) {
  frontStyle = myFrontDoc.paragraphStyles.item(backStyles[j]);
  if (frontStyle == null) continue;
  backStyle = myBackDoc.paragraphStyles.item(backStyles[j]);
  backStyle.pointSize = frontStyle.pointSize;
  backStyle.leading = frontStyle.leading;
}
Notice that I avoid messing with No Paragraph Style by counting down to one and not zero in the loop. Not a very remarkable script, but definitely quicker to write and more reliable than doing the job manually -- provided, of course, that I remembered which was supposed to be at the back and which at the front. I did.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?