🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
2 messages
2 total messages Started by Rasmus_Olsen Thu, 26 Mar 2009 15:19
[CS3 JS] event crashes InDesign
#338
Author: Rasmus_Olsen
Date: Thu, 26 Mar 2009 15:19
61 lines
2929 bytes
Scripting ladies and gentlemen,

I'm working on this event script that searches for linked PDF files and lets the user copy/relink them. Using the afterOpen eventListener however crashes InDesign no matter what I do. This is also the case with beforeClose. It appears that my function cnvrtPDFlnk is causing the crash (I'm able to alert succesfully with the afterOpen event if I //-comment the cnvrtPDFLnk(myDocument)). Do one of you scripting gurues have a hint?



#targetengine "session"

main();

function main() { 
   app.addEventListener("afterOpen", myEventFunction, false); 
}

function myEventFunction(myEvent) { 
   var myDocument = myEvent.parent; 
   var label = docLabel(myDocument, "PDFCheck"); 
   if(label) { 
      //myEvent.stopPropagation(); 
      //myEvent.preventDefault(); 
      exit(); 
   } 
   else { 
      cnvrtPDFLnk(myDocument); 
   } 
}

function docLabel(myDocument, key) { 
   var hasLabel = (eval(myDocument.extractLabel(key))?true:false); 
   return hasLabel; 
}

function cnvrtPDFLnk(myDocument) { 
   var graphics = myDocument.allGraphics; 
   var link; var linkExt; var linkType; var linkPath; var linkPageRef; var myConfirm; var myFolder; var myFile; var myOrgPath; 
   var myLinkObjects = []; 
   for (var i = 0; i < graphics.length; i++) {           
      link = graphics[i].itemLink; 
      linkExt = link.filePath.split('.').pop().toLowerCase();    
      linkType = link.linkType.toLowerCase();          
      if (linkExt == 'pdf' || linkType.match('pdf') != null) { 
         link.show(); 
         if(myConfirm= confirm(link.name+"\nDo you want to convert this link?")?myLinkObjects.push(link):alert("Link skipped!\n"+link.name)); 
      } 
   } 
   if (myLinkObjects.length > 0) { 
      myFolder = Folder.selectDialog("Point me to a hotfolder.."); 
      copyLink(myLinkObjects, myFolder); // run copyLink function - copies links according to myfolder 
      if(myConfirm = confirm("Do you want to relink now?")) { 
         reLink(myLinkObjects); // run reLink function - relinks according to myFile dialogue 
         app.menuActions.item("Fit Page in Window").invoke(); 
         app.menuActions.item("First Page").invoke();       
      } 
   myDocument.insertLabel("PDFCheck", "true"); 
   }// no links 
}// end cnvrtPDFLnk



Best regards,
Rasmus
Re: [CS3 JS] event crashes InDesign
#347
Author: Kasyan_Servetsky
Date: Thu, 26 Mar 2009 17:37
9 lines
856 bytes
Hi Rasmus,

This problem was discussed earlier:
 <http://www.adobeforums.com/webx/.59b71ef3/1>
 <http://www.adobeforums.com/webx?128@@.59b6ab75>

Instead of InDesign&#8217;s afterOpen event use Rorohico APID Toolkit&#8217;s docLoaded event. It works ok.

Kasyan
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads