4 Replies Latest reply on Jul 24, 2011 7:05 PM by DiggerManAgain

    Carriage return being added to the end of URL hyperlinks

    DiggerManAgain

      I have a list of hundreds of URLs that are generated on to an Excel spreadsheet that my colleague has added as hyperlinks on to image frames within InDesign CS5.

       

      He added them as a URL hyperlink, but left the 'shared hyperlink destination' box ticked so they were automatically converted to Shared Destination links on creation.

      I exported the INDD file to SWF, all of the hyperlinks worked fine once I tested them on a live server. However, when I exported the same INDD document into a PDF(Interactive) document the same links did not work. The links show as they should within the PDF, ending with 'pagename.aspx', but once you open the link in any browser it has a hexidecimal carriage return on the end, 'pagename.aspx%0D', which invalidates the URL.

       

      I have tried every combination of creating a hyperlink within InDesign; URL, shared, shared box ticked and unticked, it made no dofference, the %0D always appeared on the end.

       

      I switched on control symbols within Excel, nothing appeared, though I am a novice at Excel.

      I copied and pasted the same URL from Excel directly into a text frame in InDesign, it showed no carriage return symbol, and there is no evidence anywhere else that there is anything hiding on the end of the URL.

       

      Today I edited a hyperlink on the same document, and reexported to SWF, now I'm having the same problem with that particular changed link, irrespective of what type of hyperlink I change it to, now from both Flash and Acrobat!

       

      Like most bugs I've encountered, InDesign turns out to be the culprit, and the new web related features never seem to work the way they claim to.

       

      I could not find any evidence on Google of someone else having a similar problem.

       

      Please help, thank you.

        • 1. Re: Carriage return being added to the end of URL hyperlinks
          John Hawkinson Level 5

          Well, i don't know what's going on here but it's easy to fix.

          Let's take the script I posted the other day in Missing http after Convert URL to hyperlink in CS5.5 and we can modify it to remove terminal carriage returns instead or prepending 'http's:

           

          var
              i,
              hls=app.activeDocument.hyperlinkURLDestinations;
          for (i=0; i<hls.length; i++) {
              if (!hls[i].destinationURL.match(/\s$/)) {
                   hls[i].destinationURL = hls[i].destinationURL.replace(/\s*$/,"");
              } }

           

          Which matches any URLs that have terminal whitespace (one or more characters) and removes the whitespace (replaces it with nothing).

          Still untested though.

           

          And if for some freaky reason you have URLs which are supposed to have spaces at the end...you should go out and find a polite way to tell the people creating those URLs that they are Wrong.

          • 2. Re: Carriage return being added to the end of URL hyperlinks
            DiggerManAgain Level 1

            thanks for your help, the scripts seems to run fine but doesn't remove the %0D(carriage return) on the end of the URLs, I exported an interactive PDF a couple times and they're still there.
            I'm guessing it may be because the hyperlinks were converted to Link to:Shared destination, rather than Link to:URL?

            It would be good if I could change them all to URL rather than shared in one hit but I'm unaware of a way to do that without losing the destinations, and I don't have time to do so seperately as there are hundreds of them.

             

            I don't know the built in parameters for InDesign scripting, is there one that can replace the terms in your script to address Shared destination links rather than straight URL links?

             

            IDhyperlinks.jpg

            • 3. Re: Carriage return being added to the end of URL hyperlinks
              John Hawkinson Level 5

              I don't think that's the problem. I believe shared destination URLs still show up as hyperlinkURLDestinations.

              Try adding

               

              $.writeln(hls[i].destinationURL);
              

               

              before the if() to print out a line in the ESTK console for each URL it encounters.

               

              Oh wait! Ha ha ha. Upon further inspection, I see the problem... please remove the exclamation point (!) from the start of the if()...

              The script I modified tested for the ABSENCE of something before doing the replacement. But that's the opposite here, where you are testing for the presence. "!" means 'not". sigh...

               

              Sorry about htat...

              • 4. Re: Carriage return being added to the end of URL hyperlinks
                DiggerManAgain Level 1

                Brilliant, that works perfectly, thank you very much