• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Overtext script request

New Here ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

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!

TOPICS
Import and export , Scripting

Views

185

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 15, 2022 Oct 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. Simpl

...

Votes

Translate

Translate
Advisor ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines