Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Remove Empty Pages Performance

$
0
0

I have an 82 page InDesign CS6 document that was created from a database publishing program. Every other page is blank, so I have a script to delete the empty pages:

 

#target indesign

app.doScript(main, undefined, undefined, UndoModes.entireScript,"Remove Blank Pages");

function main () {

    if (app.documents.length === 0) {        alert ("Please open a document.");        return;    }    app.scriptPreferences.enableRedraw = false;    // Remove the blank pages in the document.    removeBlankPages (app.activeDocument);        app.scriptPreferences.enableRedraw = true;

}

function removeBlankPages (doc) {
        var pages = doc.pages;    var count = pages.length - 1, i = 0;    for (i = count; i >= 0; i -=1) {        if (pages[i].allPageItems.length === 0) {            pages[i].remove ();        }    }
}

 

I am running Windows 7 with 12 GB of RAM and a i7 processor and it takes the script just under 2 minutes to delete around 40 pages. I am a little surprised at how long this script takes to run. Does anyone have any suggestions for making it faster? It is not critical--obviously it is faster than doing it by hand--but I thought it should work a little faster. Thanks in advance.

 

Rick


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>