Skip to main content
Vagaso
Participant
October 11, 2022
Answered

Overtext script request

  • October 11, 2022
  • 2 replies
  • 327 views

I'm looking for a script I can use to check for overtext inside a batch format converter script by Peter Kahrel. Due to my work, I cant just hope there's no overtext in a file. The Batch process im using does check for all other errors but not overtext. Any help would be appreciated!

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Peter Kahrel

You need to change two small things in Mike's script to make it work in the batch processor.

1. The last two lines stop the script. If you want to keep it running and add entries to the error report shown after the script finishes, change the penultimate line to

 

batch_problems.push (app.documents[0].name + " contains overset text on page(s): \r" + pageList);

 

and delete the last line (the one that says exit();

 

2. You need to ring-fence the script to shield the batch converter from it. Simply add this line at the very start of the script:

 

(function () {

 

and add this at the very end:

 

}());

 

That's all!

P.

2 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
October 15, 2022

You need to change two small things in Mike's script to make it work in the batch processor.

1. The last two lines stop the script. If you want to keep it running and add entries to the error report shown after the script finishes, change the penultimate line to

 

batch_problems.push (app.documents[0].name + " contains overset text on page(s): \r" + pageList);

 

and delete the last line (the one that says exit();

 

2. You need to ring-fence the script to shield the batch converter from it. Simply add this line at the very start of the script:

 

(function () {

 

and add this at the very end:

 

}());

 

That's all!

P.

Legend
October 11, 2022

Hello @Vagaso,

 

Give this script a try...

   var myResult = {};
   var allStoriesArray = app.documents[0].stories.everyItem().getElements();
   
    for(var n=0; n<allStoriesArray.length; n++){
    var currentStory =  allStoriesArray[n];
    var textContainersLength = currentStory.textContainers.length;
    var lastFrameOfStory = currentStory.textContainers[textContainersLength-1];
    var objToCheck = lastFrameOfStory;
    
    if(lastFrameOfStory.constructor.name == "TextPath")
    objToCheck = lastFrameOfStory.parent
    
    if(currentStory.overflows && objToCheck.itemLayer.visible && objToCheck.parentPage != null)
    myResult[objToCheck.parentPage.name] = objToCheck.parentPage.name;
    }
    
    var pageList = new Array;
    for(var a in myResult)
    pageList.push(a);
        
    pageList.sort(function(a,b) {return a-b});
    
    if(pageList.length > 0){
    alert("Error!\nDocument contains overset text on page(s): \r" + pageList);
    exit();
    }

Regards,

Mike