Sunday, January 15, 2006


How many changes were there?

The current document I'm working on has 161 pages. It takes about 15 minutes for my iMac G5 (2 GHz) to export a pdf. After sitting through one such export, I suddenly remembered that I'd not run the script I discussed here: Quick & Dirty Leading Fixer.

Well, that script was so quick and dirty there was no way to tell if it actually did anything -- indeed, from InDesign's point of view it changed every text frame with a paragraph in the style format. So, if I ran that script, I'd have no choice but to export the pdf again.

A new version of the script was called for that would count the changes and tell me how many. So I modified the script to this:
//DESCRIPTION: Format head leading fixer

myDoc = app.activeDocument;
app.findPreferences = null;
app.changePreferences = null;
myFinds ="",false,false,undefined,{appliedParagraphStyle:myDoc.paragraphStyles.item("format")});
myCount = 0;
for (var j=myFinds.length - 1; j >= 0; j--) {
 if (myFinds[j].parentTextFrames[0].textFramePreferences.firstBaselineOffset != FirstBaseline.leadingOffset) {
  myFinds[j].parentTextFrames[0].textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;
alert(String(myCount) + " change" + ((myCount == 1)? "" : "s") + " made.");
Notice that decision in the middle of the alert string. I hate it when alerts say things like "1 changes made." It is that easy to test for the value 1 and suppress the "s" on "changes" so why not?

Oh, and the good news is that this time I didn't have to re-export the PDF!

Comments: Post a Comment

<< Home

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