[Script] Deleting pages in bulk from a big document painfully slow
Hi Folks,
The issue is simple if we try to delete lots of pages from a big document say 2000 pages long, the process is very slow. A simple code snippet like the following takes ages to complete. For my testing I used a blank document with 2000 pages, I am sure for a fully composed production document the time will be more
for (i=0; i<50; i++)
app.documents[0].pages[i].remove();
Here I am trying to delete the pages in sequence but a practical scenario would be deleting specific pages. This issue was reported in response to another query posted on the forum for which I posted a potential code snippet
I tried different things like
- Reducing the undo stack entry by calling the deletion call from within doScript to have a single undo entry
- Opening the document without a window
- Try the move method to move all the pages to delete at the end and then maybe use pagePerDocument property to remove those pages. But the move method causes the same time issue
Any ideas on how to speed this up? If we try to delete these pages using the pages panel it deletes much quicker so this has something to do with the communication of DOM with the InDesign objects in my opinion. Any insights would be really helpful
-Manan
