Skip to main content
Participant
August 6, 2024
Question

preflight result need to extract page numbers for overset text result

  • August 6, 2024
  • 2 replies
  • 209 views
 

Here is your text with corrected grammar:


Hi All,

I am facing an issue while extracting page numbers from the given overset text result.

Here is the result: prefresultsForOversetText = myPreflightProcess.aggregatedResults.

Here is the prefresultsForOversetText returning an array:


 
"test.indd,Preflight_profile,1,TEXT (3),,,,2,Overset text (3),,,,3,Text Frame,2,Problem: Overset text: 108 characters
Fix: Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary.,Problem,Overset text: 108 characters,Fix,Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary.,3,Text Frame,4,Problem: Overset text: 108 characters
Fix: Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary.,Problem,Overset text: 108 characters,Fix,Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary.,3,Text Frame,5,Problem: Overset text: 429 characters
Fix: Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary.,Problem,Overset text: 429 characters,Fix,Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary."
rames to the story thread if necessary.,Problem,Overset text: 429 characters,Fix,Resize the text frame, or edit the text to fit within the frame. Add text frames to the story thread if necessary."

I need to extract the page numbers.

Can anyone help me? Do we have any direct method to get the page number from the result?

Thanks in advanc



 

This topic has been closed for replies.

2 replies

Robert at ID-Tasker
Legend
August 6, 2024

@@riteshg

 

What is your end goal? 

 

Why not just iterate through Stories collection and check overset property?

 

And of course Cells in Tables. 

 

m1b
Community Expert
Community Expert
August 6, 2024

I know what you mean @@riteshg! The aggregatedResults is a gnarly mess: an ordered array of ordered arrays, with each element a specific thing. (It should be it's own Object, with sensible keys, but... oh well) I've never worked with it before, but as far as I can tell, here is a basic approach that works fine in my test document. Let me know if it works for you.

- Mark

 

/**
 * @file List pages with overset text.js
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/preflight-result-need-to-extract-page-numbers-for-overset-text-result/m-p/14781671
 */
function main() {

    if (0 === app.preflightProcesses.length)
        alert('No preflight processes active. Please try again later.');

    // store the overset page names in an object
    var oversets = {},
        hasOversetText = /Problem: Overset text/,
        extension = /\.[^\.]+$/;

    for (var i = 0, pf, docName, problems; i < app.preflightProcesses.length; i++) {

        pf = app.preflightProcesses[i];

        // use the doc name, without extension, as key
        docName = pf.aggregatedResults[0].replace(extension, '');

        // make an array in oversets for this document
        oversets[docName] = [];

        // collect the overset warnings for this document
        problems = pf.aggregatedResults[2];
        for (var j = 0; j < problems.length; j++)
            if (hasOversetText.test(problems[j][3]))
                // store the page name for this overset error
                oversets[docName].push(problems[j][2])

    }

    // show results
    var message = '',
        counter = 0;

    for (var key in oversets) {
        if (
            oversets.hasOwnProperty(key)
            && oversets[key].length > 0
        ) {
            message += 'Document: "' + key + '"\n  Pages ' + oversets[key] + '.\n\n';
            counter += oversets[key].length;
        }
    }

    if (0 === counter)
        alert('There are no active overset warnings.');

    else
        alert('There are ' + counter + ' active overset warnings\n' + message);

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'List pages with overset text');

 

 

 

EDIT 2024-08-06: updated script to handle multiple preflight processes (eg. when multiple documents are open).