6 Replies Latest reply on Apr 9, 2013 7:09 AM by BEGINNER_X

    Image Problem

    BEGINNER_X Level 3

      Hi All,

       

      Request:

       

      For my script I want to copy all graphics from source document and paste in target document.

       

      But for one particular art, the script is quit. That art name not comes in "Link" also (refer screenshot).

       

      I dont know what format it is like tiff, eps etc.....

       

       

      Please find the screenshot:

       

      Screen Shot 2013-04-09 at 3.21.35 PM.png

       

      Trying Script(work fine all arts exept above mentioned art):

       

      var mySourceDocument = app.documents[0]

      var myDocName = mySourceDocument.name

      myDocName = myDocName+"";

      var ImageSizes = new Array;

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

        var docSource = app.documents.item(myDocName);     // input the proper name

      var docDestination = app.documents.item("testing.indd")     // input the proper name

       

      var myGraphics = mySourceDocument.allGraphics

      for (i = 0; i < myGraphics.length; i++) {

              var myGraphicsName = myGraphics[i].itemLink.name;

                  myGeometricBounds = myGraphics[i].parent.geometricBounds

           var myWidth = myGeometricBounds[3] - myGeometricBounds[1]

           var myHeight = myGeometricBounds[2] - myGeometricBounds[0]

       

          if (i == 0) {

              app.activeWindow = docSource.windows.item(0);

              app.select(myGraphics[i].parent);

              app.copy();

              app.activeWindow = docDestination.windows.item(0);

              app.paste();

          }

       

          if (i != 0) {

              app.activeWindow = docSource.windows.item(0);

              app.select(myGraphics[i].parent);

              app.copy();

              app.activeWindow = docDestination.windows.item(0);

              app.paste();

          }

      }

       

       

      Please find the error screenshot while running the script:

       

      Screen Shot 2013-04-09 at 3.55.21 PM.png

       

      Could anyone give solution for my problem.

       

       

      Thanks

      BEGINNER_X

        • 1. Re: Image Problem
          Kasyan Servetsky Level 5

          This image was created by copying it from another application and pasting it into InDesign. That's why it is not a link and has no itemLink property. The error occurs when the script tries to access it.

          • 2. Re: Image Problem
            BEGINNER_X Level 3

            Hi Kasyan,

             

            Thanks for your quick response..

             

            Please give any solution for my script for copy and paste from source document and target document.

             

            Customer using that kind of art also.

             

             

            Trying in below way. It not to be sucess

            LinkStatus.NORMAL

            LinkStatus.LINK_OUT_OF_DATE

            LinkStatus.LINK_MISSING

            LinkStatus.LINK_EMBEDDED

            LinkStatus.LINK_INACCESSIBLE

             

             

            Thanks

            BEGINNER_X

            • 3. Re: Image Problem
              Kasyan Servetsky Level 5

              As far as I know, placing an image without creating a link (by coping & pasting) is possible on Mac only. But I'm currently on PC.

              • 4. Re: Image Problem
                [Jongware] Most Valuable Participant

                You are not using the variable "myGraphicsName" *anywhere* else in the rest of your script. What happens if you remove this line?

                1 person found this helpful
                • 5. Re: Image Problem
                  Vamitul Level 4

                  Kasyan, it's posibile on pc too.

                  Beginner, the entire

                   

                          var myGraphicsName = myGraphics[i].itemLink.name;
                              myGeometricBounds = myGraphics[i].parent.geometricBounds
                       var myWidth = myGeometricBounds[3] - myGeometricBounds[1]
                       var myHeight = myGeometricBounds[2] - myGeometricBounds[0]
                  
                  

                  is unneded.

                  Also, try to avoid using copy and paste functions whenever possible, they slow down the script a lot.

                  Another note, you should make a habbit of ending your statements with ;

                  • 6. Re: Image Problem
                    BEGINNER_X Level 3

                    Hi Jongware/Vamitul/Kasyan,

                     

                    Thank you for your response....

                     

                    This one is part of  script only.

                     

                    Image without link name on that time my script quit.

                     

                     

                    Now Using the below code without error:

                     

                    try{      

                    var myGraphicsName = myGraphics[i].itemLink.name;

                    }

                    catch(myError)

                    {}

                     

                    Now my script works fine.

                     

                    Thanks

                    BEGINNER