Copy link to clipboard
Copied
In a script i create pages, export to pdf, remove pages and then create again etc.
At the moment i use this:
for(var j = b.pageCount(); j > 1; j--) {
b.removePage(j);
}
But it is really slow. I think indesign does a lot of calculating after removing a page (due link textfields) so it would be more efficient to remove all the pages at once.
Now my question is how can i do that?
I tested and if i delete about 5500 empty pages with the script it takes around 8 minutes.
If i select them all in indesign and then delete it takes around 10 seconds.
Another way to speed up a litle is to clear all the content. It will still take long but probably a bit faster.
Thing is i have
b.clear(b.doc());
but this remove the master page as well and i need to keep the master page.
In short, how can i remove all pages (except one since indesign needs one page) at once?
Hi,
i do removing many pages in indesign with
here is test code, run with old Macbook Air + CS5 + OSX10.7
...var pp = function (args) {
$.writeln(args);
}
var remove_all_pages_use_pref = function (doc) {
pp("start deleting (use preferences)");
$.hiresTimer;
doc.documentPreferences.pagesPerDocument = 1;
pp("end deleting");
pp($.hiresTimer);
}
var remove_all_pages_use_loop = f
Copy link to clipboard
Copied
Hi,
i do removing many pages in indesign with
here is test code, run with old Macbook Air + CS5 + OSX10.7
var pp = function (args) {
$.writeln(args);
}
var remove_all_pages_use_pref = function (doc) {
pp("start deleting (use preferences)");
$.hiresTimer;
doc.documentPreferences.pagesPerDocument = 1;
pp("end deleting");
pp($.hiresTimer);
}
var remove_all_pages_use_loop = function (doc) {
var i = doc.pages.length;
pp("start deleting (while --)");
$.hiresTimer;
while (i--) {
if (i==1) {break;}
doc.pages.remove();
}
pp("end deleting");
pp($.hiresTimer);
}
function main() {
var doc = app.documents.add();
$.hiresTimer;
doc.documentPreferences.pagesPerDocument = 5500;
pp('# create 5500 pages');
pp($.hiresTimer);
var indd = new File("~/Desktop/5500.indd");
doc.save(indd);
pp("------------");
remove_all_pages_use_pref(doc);
doc.close(SaveOptions.NO);
pp("------------");
pp("# try another way");
var doc2 = app.open(indd);
remove_all_pages_use_loop(doc2);
doc2.close(SaveOptions.NO);
}
main();
result
# create 5500 pages 30395026 ------------ start deleting (use preferences) end deleting 28215999 ------------ # try another way start deleting (while --) end deleting 268641063
thanks
mg
Copy link to clipboard
Copied
looks promosing!
How can i do this on the current document?
I tried:
var doc = app.documents.current();
And i did found a html reference for indesign but if i did a search on app i had more then 500 hits and the same for document so that wasn't really helping.
thanks
Copy link to clipboard
Copied
var doc = app.activeDocument should do it.
Copy link to clipboard
Copied
thanks!
so in short:
var doc = app.activeDocument;
doc.documentPreferences.pagesPerDocument = 1;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more