Adobe InDesign hangs indefinitely when I try to duplicate pages using ExtendScript -


i have simple extendscript script creates new document out of subset of current active document:

var sourcedocument = app.activedocument; var i, j;  for(i = 0; < sourcedocument.layers.length; i++) {   sourcedocument.layers.item(i).locked = false; } for(i = 0; < sourcedocument.spreads.length; i++) {   for(j = 0; j < sourcedocument.spreads.item(i).textframes.length; j++) {     if(sourcedocument.spreads.item(i).textframes.item(j).locked) {       sourcedocument.spreads.item(i).textframes.item(j).locked = false;     }   } }  var destdocument = app.documents.add(); var firstpageindex = 0; // in actual script, chosen user. var lastpageindex = 5; // in actual script, chosen user.  destdocument.importstyles(importformat.paragraphstylesformat, new file(sourcedocument.filepath + "/" + sourcedocument.name), globalclashresolutionstrategy.load_all_with_overwrite); destdocument.importstyles(importformat.characterstylesformat, new file(sourcedocument.filepath + "/" + sourcedocument.name), globalclashresolutionstrategy.load_all_with_overwrite); destdocument.viewpreferences.horizontalmeasurementunits = sourcedocument.viewpreferences.horizontalmeasurementunits; destdocument.viewpreferences.verticalmeasurementunits = sourcedocument.viewpreferences.verticalmeasurementunits; destdocument.documentpreferences.facingpages = sourcedocument.documentpreferences.facingpages; destdocument.documentpreferences.pageheight = sourcedocument.documentpreferences.pageheight; destdocument.documentpreferences.pagewidth = sourcedocument.documentpreferences.pagewidth; destdocument.documentpreferences.pagesize = sourcedocument.documentpreferences.pagesize; destdocument.documentpreferences.allowpageshuffle = true;  var range = sourcedocument.pages.itembyrange(firstpageindex, lastpageindex); range.duplicate(locationoptions.after, destdocument.pages[destdocument.pages.length - 1]); destdocument.pages[0].remove(); // empty spread containing empty page added when new document created , cannot remove before other pages inserted (documents must have @ least 1 page) 

this script works on many documents. when execute against 1 particular document (let's call foo.indd), indesign becomes unresponsive when executing duplication: range.duplicate(locationoptions.after, destdocument.pages[destdocument.pages.length - 1]);. on, thing can force indesign quit.

is indesign bug? how can find part of particular document creating problem?

i can't what's wrong in example if indesign hangs, might caused loops ( infinity , beyond :) )

so may try avoid issues outputting loop limit avoid indesign re-calculation

var limit = … ( = 0; i<limit ; i++)… 

additionally try write info on console info indesign being stuck. write informations on fly on report file , might identify issue area.

also, can try interrogate every key items see if file has issue.

last not least, try manual export idml of file, re open , run again script. files become clunky , passing idml fix of them.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -