3 Replies Latest reply on Jul 21, 2016 11:55 AM by schattenjager

    Issue with InDesign startup script not loading images from XML import

    schattenjager

      I am trying to do an XML import automatically from a startup script when a document is loaded. I am successful in getting most of the content to populate, but images are being ignored. Everything works, including images, when I do a manual 'Import XML' through the UI, or through a manual script.

       

      Below is my manual script:

      var myDocument = app.activeDocument;
      var xmlFile = File('/c/Full/Path/To/data.xml');
      
      myDocument.importXML(xmlFile);

       

      But the goal is to do it on startup. Below is my startup script:

      #targetengine "session"
      
      app.addEventListener('afterOpen', function(myEvent) {
         if (myEvent.target.constructor.name !== 'Document') {
         return;
         }
      
         var myDocument = myEvent.target;
         var xmlFile = File('/c/Full/Path/To/data.xml');
      
        myDocument.importXML(xmlFile);
      });

       

      Below is the XML tag for the image:

      <Image href="file:///C:/Full/Path/To/Image/02.png" />

       

      I'm wondering if there is an issue with the 'afterOpen' event callback, and that's the reason why it works manually using the same method, but not in the startup script.