9 Replies Latest reply on Apr 11, 2009 8:41 PM by Amit Vyawahare

    [JS OSX problem executing CS3 script in CS4 ]

      I created a program in CS3 for hyperlink. Following code will work fine in CS3. But when i am trying to run this program in CS4 its not giving me any error but i am not getting  expected output.

       

      var myTextFrame_np = mydoc.pages.item(i).textFrames.add();

      myTextFrame_np.geometricBounds = ["38p0", "26p0", "40p0", "30p0"];

      var source_np = mydoc.hyperlinkPageItemSources.add(myTextFrame_np,{name:'P1:P2'});

      var dest_np = mydoc.hyperlinkExternalPageDestinations.add();

      dest_np.documentPath = myfile;

      dest_np.destinationPageIndex = 2;

      dest_np.viewSetting = HyperlinkDestinationPageSetting.fitWindow;

      mydoc.hyperlinks.add(source_np, dest_np, {visible:false, name:'P1:P2'});

       

      Can anyone tell me what i need to change in this program to work in CS4.

       

      Thank you,

      --Amit

        • 1. Re: [JS OSX problem executing CS3 script in CS4 ]
          Dave Saunders Level 4

          Amit,

           

          I suspect that the reason nobody has answered you is:

           

          1. You assume that we can discern what "the expected result" is.

           

          2. You've not provided enough code to make it possible to just run the script.

           

          3. You require us to first run it in CS3 to see what is supposed to happen so we can then run it in CS4 to find out what doesn't happen.

           

          Dave

          • 2. Re: [JS OSX problem executing CS3 script in CS4 ]
            Level 1

            Let me ask this question in other way. Is there any way to open this hyperlink (P1:P2) save the changes and close it.

            When you run that code it will create an  hyperlink. My question is is there any way we can open this hyperlink save it one more time and close it.

            I tryed manually it works. I just need a way how to open this hyperlink using JS.

             

            If you can see the attachment. You will get to know this code will generate a hyperlink name P1:P2.

            If you notice there is a small icon when you double click the hyperlink it will go away and that hyperlink will work.

            If you know way to open this hyperlink you can solve my problem.

             

            Let me know if you need any think else from me. Thank you for your help.

             

            --AMit

            • 3. Re: [JS OSX problem executing CS3 script in CS4 ]
              Dave Saunders Level 4

              Does:

               

              myHyperlink.showDestination();

               

              do what you want?

               

              I don't know that you can from JavaScript "close" such a link though, once opened.

               

              Dave

              1 person found this helpful
              • 4. Re: [JS OSX problem executing CS3 script in CS4 ]
                Level 1

                This function (myHyperlink.showDestination(); ) will show you destination for this link.

                 

                If you check menu of that hyperlink there is one more option called Hyperlink Option.. Is there any way we can open Hyperlink Option..

                 

                Step to solve this problem.

                 

                1) Open  Hyperlink Option.. for that hyperlink('P1:P2');

                2) Click OK.

                 

                This two step will solve the problem. Do you have any idea how to open this Hyperlink Option.. function.

                 

                Thank you for your help.

                 

                --Amit

                • 5. Re: [JS OSX problem executing CS3 script in CS4 ]
                  Dave Saunders Level 4

                  I believe you'll need to use invoke to invoke the command that opens the dialog. But I don't think you can click OK from a script.

                   

                  Dave

                  1 person found this helpful
                  • 6. Re: [JS OSX problem executing CS3 script in CS4 ]
                    Level 1

                    How do i invoke the command that opens the dialog. Can you give me some example.

                     

                    -Amit

                    • 7. Re: [JS OSX problem executing CS3 script in CS4 ]
                      Level 1

                      I created a test case for you. Copy the code into ESTK and run for CS4. I am sending Amit.indd file as well in your mail box please check the attachment. You can check now what is the problem. 

                       

                       

                       

                      var file_path = "/Users/amitvyawahare/Desktop/Amit.indd";

                      var OpenDocument = app.open(File(file_path));

                      myDoc = app.activeDocument;

                      var myfile = File(file_path);

                       

                      var nextPage = ["38p5", "26p0", "40p0", "30p0"];  // Next Page text frame for hyperlink (y1, x1, y2, x2)

                      var prevPage = ["38p5", "21p0", "40p0", "25p0"];  // Previous Page text frame for hyperlink (y1, x1, y2, x2)

                       

                      var myNextFrame = myDoc.pages.item(0).textFrames.add();

                      myNextFrame.geometricBounds = [nextPage[0], nextPage[1], nextPage[2], nextPage[3]]; 

                      var myNextSource = myDoc.hyperlinkPageItemSources.add(myNextFrame,{name:'P1:P2'});

                      var myNextDest = myDoc.hyperlinkExternalPageDestinations.add();

                      myNextDest.documentPath = myfile;

                      myNextDest.destinationPageIndex = 2;

                      myNextDest.viewSetting = HyperlinkDestinationPageSetting.fitWindow;

                      myDoc.hyperlinks.add(myNextSource, myNextDest, {visible:false, name:'P1:P2'});

                       

                      When you finish execution try to open the showDestination it wount work.

                      But  when you open P1:P2 hyperlink or try to open hyperlink option which is under hyperlinks.

                      Then try to open showDestination that time it will work.

                       

                      --Amit

                       

                       

                      • 8. Re: [JS OSX problem executing CS3 script in CS4 ]
                        Dave Saunders Level 4

                        The problem appears to be that you are trying to use an externalPageDestination to point at the same document as the source. Apparently CS3 allowed that but CS4 doesn't.

                         

                        This works (notice I had to refer to a particular page not just an index to the page):

                         

                        var file_path = "~/Desktop/Amit.indd";
                        var OpenDocument = app.open(File(file_path));
                        myDoc = app.activeDocument;
                        var myfile = File(file_path);

                         

                        var nextPage = ["38p5", "26p0", "40p0", "30p0"];  // Next Page text frame for hyperlink (y1, x1, y2, x2)
                        var prevPage = ["38p5", "21p0", "40p0", "25p0"];  // Previous Page text frame for hyperlink (y1, x1, y2, x2)

                         

                        var myNextFrame = myDoc.pages.item(0).textFrames.add();
                        myNextFrame.geometricBounds = [nextPage[0], nextPage[1], nextPage[2], nextPage[3]];
                        var myNextSource = myDoc.hyperlinkPageItemSources.add(myNextFrame,{name:'P1:P2'});
                        var myNextDest = myDoc.hyperlinkPageDestinations.add();
                        myNextDest.destinationPage = myDoc.pages[1];
                        myNextDest.viewSetting = HyperlinkDestinationPageSetting.fitWindow;
                        myHlink = myDoc.hyperlinks.add(myNextSource, myNextDest, {visible:false, name:'P1:P2'});

                         

                        Dave

                        • 9. Re: [JS OSX problem executing CS3 script in CS4 ]
                          Level 1

                          Thank you sir. Got my answer. I think your scripting knowledge is best in this business.

                          Thank you for your help.

                           

                          --Amit