21 Replies Latest reply on Jul 26, 2013 9:24 AM by juliecracker

    specify target in URLs for buttons or hyperlink settings

    MaureenD Level 1

      I've been searching for hours on this simple question. How can you specify target="_blank" on a URL?

       

      I have an InDesign CS5 document with many hyperlinks in it. Actually they have been formatted as buttons with a "go to URL' action.

       

      When converting to a PDF file, some browsers open the file in Acrobat Reader, but others open directly in the browser via a plugin. In the latter case, I want the links to open in a new window (or tab) rather than overtaking the window containing the PDF.

       

      I can't believe there isn't an option in InDesign to specify a target on URLs. I don't mind converting all of the buttons to hyperlinks, but neither panel has this option.

       

      I know it can be done via Acrobat, (see http://acrobatusers.com/blogs/tedpadova/opening-pdfs-new-browser-windows) but obviously this means redoing every one of them after having to make any change to the InDesign file.

       

      Can any of you scripting gurus tell me how to do this?

        • 1. Re: specify target in URLs for buttons or hyperlink settings
          [Jongware] Most Valuable Participant

          Sorry to disappoint you, but you are looking for something that cannot be scripted. The only thing you can set in InDesign is the URL -- nothing else. "target" is something else, hence you cannot set its value.

           

          (Uh. In more technical detail: the text you enter in InDesign as 'the link' of a hyperlink, whether it is with scripting or in the UI dialog, appears in the 'href' attribute in the hyperlink. You cannot set any value for the 'target' attribute, and you cannot add any attribute/value pair you want either. So it's a limitation of what you can and cannot do with InDesign. It's not so much a "simple question", believe it or not, it's more that ID is not designed to handle any random HTML coding.)

          • 2. Re: specify target in URLs for buttons or hyperlink settings
            MaureenD Level 1

            Wow. Well, thanks for the answer.

             

            It's hard to believe that there is not a way around this. I was hoping there might be a javascript snippet that ID would parse to accomplish this.

            • 3. Re: specify target in URLs for buttons or hyperlink settings
              John Hawkinson Level 5

              Are we sure there's no way to use a javascript link?

              I would naively think javascript:window.open("http://www.adobe.com/") would work and it almost does -- Acrobat throws up a noisy warning saying that it will execute the javascript if you Allow it, and then it tries but doesn't work (for me, at least).

               

              Now, certainly you can't adjust other attributes of an <A> tag since there is no such tag. But since the PDF can have embedded javascript, you would think you could specify it from InDesign.

               

              (What I suggested above is not the same. It's using a javascript scheme inside a URL field, which would be passed to the browser. But PDFs can have things other than URLs in hyperlinks, such as raw javascript that is executed by the PDF reader. And that's what the acrobatusers link is about.)

               

              I don't use InDesign for interactive stuff, but this certainly does seem like a significant omission.

               

              Wait...what does this have to do with scripting?

               

              So, of course you can fix this by postprocessing your PDF file after you have produced it from InDesign.

              Unfortunately, I can't recommend a decent platform for such postprocessing. The last time I tried to script Acrobat Pro it was horrible failure, so I ended up doing it in Java using iText.

              • 4. Re: specify target in URLs for buttons or hyperlink settings
                Laubender Adobe Community Professional & MVP

                Maureen,

                it should be possible to send over the Acrobat JavaScript code for the postprocessing phase in Acrobat Pro through pdfmarks embedded in EPS files on the InDesign page. Downside is that you need Acrobat Distiller to generate the PDF.

                 

                EPS files could be simple text files generated by ExtendScript and placed according to your URLs.
                Just a thought…
                Not tested.

                 

                For code samples of pdfmarks and the whole process look for the PostScript & PDF Bible by Thomas Merz and Olaf Drümmer.
                Especially see chapter 11.8 JavaScript with pdfmarks.

                 

                Uwe

                • 5. Re: specify target in URLs for buttons or hyperlink settings
                  Laubender Adobe Community Professional & MVP

                  Here a follow-up: indeed it's possible.

                   

                  The Code for the EPS file would be something like this:

                   

                  %!PS-Adobe-3.0 EPSF-3.0
                  %%BoundingBox: 0 0 100 100
                  %%EndProlog
                  
                  [ /Rect [ 0 0 100 100 ]
                  /Action << /Subtype /JavaScript /JS (app.launchURL\("PLACE-YOUR-URL-HERE", true\);) >>
                  /Subtype /Link
                  
                  /ANN pdfmark
                  
                  %%EOF
                  

                   

                  Of course, BoundingBox and Rect coordinates should be adapted to fit the url text in InDesign. The EPS could be placed as an inline object above etc., etc.
                  I hope you get the idea.

                   

                  Uwe

                  • 6. Re: specify target in URLs for buttons or hyperlink settings
                    John Hawkinson Level 5

                    It's kind of sick though. And Adobe PDF Library (what InDesign uses) doesn't support pdfmark?

                    I'm still having trouble getting over the idea that with all this interactive support in ID, there isn't direct support for embedding Javascript. I guess Adobe made a strategic decision to favor Flash? [Except it looks like you can't embed arbitrary swf code either?] Yikes...

                    • 7. Re: specify target in URLs for buttons or hyperlink settings
                      Laubender Adobe Community Professional & MVP

                      John,

                       

                      yes. It's sick…

                       

                      And support of pdfmarks in PDF Library through InDesign is null. But it seems to me that more and more features show up in the PDF export dialogs.

                      Just think of PdfMagnificationOptions, openInFullScreen, pdfPageLayout …

                       

                      And for the URLs with specific hyperlink settings the workflow could be:

                       

                      export multimedia without the hyperlinks => PDF1

                      print the EPS (pdfmark with Acrobat JavaScript-hyperlinks) only => PostScript => distill => PDF2
                      merge PDF1 with PDF2 in Acrobat Pro with the "Import as Layer"-feature

                       

                      THAT is sick…

                       

                       

                      Uwe

                      • 8. Re: specify target in URLs for buttons or hyperlink settings
                        MaureenD Level 1

                        Thanks so much for all of this information! I am going to definitely try testing this. Our team has produced many "eZines" which we just found out have this issue, so we'll have to republish all of them.

                         

                        I'll let you know how it goes!

                        • 9. Re: specify target in URLs for buttons or hyperlink settings
                          MaureenD Level 1

                          Hi Uwe,

                           

                          I think we're on the right track here, but I'm getting the following errors with Distiller:

                           

                          Distilling: pdftest.indd
                          Start Time: Wednesday, May 18, 2011 at 4:21 PM
                          Source: /Users/madunlap/Documents/PDFtesting/pdftest.indd
                          Destination: /Users/madunlap/Documents/PDFtesting/pdftest.pdf
                          Adobe PDF Settings: /Library/Application Support/Adobe/Adobe PDF/Settings/High Quality Print.joboptions
                          %%[ Error: undefined; OffendingCommand:   Ìıÿ FÂΩ1ÔÁ˛t∑ DOCUMENT p  ]%%
                          %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
                          %%[ Warning: PostScript error. No PDF file produced. ] %%
                          Distill Time: 1 seconds (00:00:01)
                          **** End of Job ****

                           

                           

                           

                          I'm not sure what the OffendingCommand is that it doesn't like.

                           

                          Here is my EPS file:

                           

                          %!PS-Adobe-3.0 EPSF-3.0
                          %%BoundingBox:0 0 16 16
                          %%EndProlog

                           

                          [ /Rect [ 86 141 230 117 ]
                          /Action << /Subtype /JavaScript /JS (app.launchURL\("http://www.google.com", true\);) >>
                          /Subtype /Link

                           

                          /ANN pdfmark

                           

                          %%EOF

                           

                          Any clue?

                           

                          Thanks so much for your help!!

                           

                          Maureen

                          • 10. Re: specify target in URLs for buttons or hyperlink settings
                            John Hawkinson Level 5
                            Distilling: pdftest.indd

                            Start Time: Wednesday, May 18, 2011 at 4:21 PM
                            Source: /Users/madunlap/Documents/PDFtesting/pdftest.indd
                            Destination: /Users/madunlap/Documents/PDFtesting/pdftest.pdf
                            Adobe PDF Settings: /Library/Application Support/Adobe/Adobe PDF/Settings/High Quality Print.joboptions

                            It looks like you're trying to distill an INDD file? Acrobat Distiller reads postscript files. So you need to print your INDD file to a PostScript file first.

                            (Also, you might try testing without the pdfmark EPS file in there and see if that works at all, as a baseline. But I'm pretty sure the above is your problem).

                            • 11. Re: specify target in URLs for buttons or hyperlink settings
                              MaureenD Level 1

                              Excellent! Yes, you're right. I was not clear on the process.

                               

                              This works, and the link now opens in a new window.

                               

                              Now, I'm wondering if there would be a way to set this up to work with any URL in the document, maybe by modifying the javascript, as there are many that would have to have the coordinates figured out for etc.

                               

                              At least this is a starting point!

                              • 12. Re: specify target in URLs for buttons or hyperlink settings
                                MaureenD Level 1

                                SOLVED:

                                 

                                I changed the EPS file to a rectangle essentially covering the entire page, then by leaving the URL definition blank, it works for any URL:

                                 

                                %!PS-Adobe-3.0 EPSF-3.0
                                %%BoundingBox:0 0 16 16
                                %%EndProlog

                                 

                                [ /Rect [ 0 0 612 792 ]
                                /Action << /Subtype /JavaScript /JS (app.launchURL\(“”, true\);) >>
                                /Subtype /Link

                                 

                                /ANN pdfmark

                                 

                                %%EOF

                                 

                                We can now include this EPS file in every eZine and just place it out in the margin where it's outside of the print area.

                                 

                                I am now doing the happy dance!

                                • 13. Re: specify target in URLs for buttons or hyperlink settings
                                  John Hawkinson Level 5

                                  I'm very confused why that would work, but congratulations! [???]

                                  • 14. Re: specify target in URLs for buttons or hyperlink settings
                                    Laubender Adobe Community Professional & MVP

                                    Me too! Congrats, Maureen!!

                                     

                                    Why is it working? A miracle…
                                    I'd like to see one PDF page of an working example. Can you provide one?

                                     

                                    Uwe

                                    • 15. Re: specify target in URLs for buttons or hyperlink settings
                                      MaureenD Level 1

                                      Please test this example:

                                       

                                      http://www.maureendunlap.com/pdftest/pdftest.pdf

                                       

                                      After all that joy and exhuberation, a colleague claimed it didn't work for him, so perhaps I was premature in my celebration :-(

                                      • 16. Re: specify target in URLs for buttons or hyperlink settings
                                        MaureenD Level 1

                                        Anyone have a chance to test this?

                                         

                                        It works with Firefox on both Mac and Windows 7. I also just upgraded my W7 browser to IE9 and it works there as well.

                                         

                                        Unfortunately does not appear to work with Safari on the Mac.

                                        • 17. Re: specify target in URLs for buttons or hyperlink settings
                                          Larry G. Schneider Adobe Community Professional & MVP

                                          If the file is opened within Safari probably using the PDF plugin, then it will work. If the file is opened in Acrobat, then it will open Firefox to operate. At least it did for me on OSX 10.5.8, Firefox 4.0.1, Safari 5.0.5.

                                          • 18. Re: specify target in URLs for buttons or hyperlink settings
                                            L. Guy O'Rojo Level 2

                                            Mac/Intel/OS X 10.5.8/Safari 4.0.4:

                                             

                                            Did not work clicking in Safari to load the PDF in the browser window (not loaded w Adobe software such as Reader or Acrobat).

                                             

                                            Did not work downloading to file and opening in Preview.

                                            • 19. Re: specify target in URLs for buttons or hyperlink settings
                                              juliecracker Level 1

                                              I know this is an older thread, but it still seems to be the only solution that has been reported to work with chrome (the Acrobat Javascript solution actually creates links that Chrome doesn't even recognize)!

                                               

                                              However, I'm a little confused: do I still need to do the two exports and then merge the layers, or is Maureen's solution not supposed to require that?

                                               

                                              I did a test using Maureen's solution (or at least I think I did :-), but the links don't open in a new window. However, I've never worked with EPS and INDD before so I might be handling the EPS file incorrectly.

                                               

                                              Any chance someone who has gotten this to work would be willing to do a little more of a step-by-step instruction?

                                               

                                              Thanks!

                                              julie

                                              • 20. Re: specify target in URLs for buttons or hyperlink settings
                                                Laubender Adobe Community Professional & MVP

                                                However, I'm a little confused: do I still need to do the two exports and then merge the layers, or is Maureen's solution not supposed to require that?

                                                 

                                                @Julie – it's more than two years, that I suggested this loop hole, but the basic situation did not change.

                                                Here the facts:

                                                 

                                                1. To transfer any information out of InDesign (all versions) for a button link URL with parameters like "true" for opening the link in a different window or tab (user specific, depends on preferences set by the user), there is no way but using PDFmarks.

                                                 

                                                2. That implies, that you are using EPS to code a button and PostScript with Distiller to render that button into a functional PDF.

                                                 

                                                A new way would be to create a HTML object in InDesign (CS6 and above) with decent code for a button and its URL. But I fear, that PDF Export or output to PostScript=>Distiller would not render that into a functional PDF button. Try it yourself…

                                                 

                                                The tricky part for #2 is getting the right code for the EPS for an existing Hyperlink or Button object in InDesign. Here I already mentioned some sources in my answer #4 above.

                                                 

                                                Since an EPS could be nothing but an ordinary text file with proper code and a specific suffix, like "*.eps", we theoretically could gather the URL from a Hyperlink in InDesign, also its geometrical dimensions (which is not straightforward) and in a second step create a new text file with PDFmarks, sneak in the URL with all wanted parameters and place that text file as EPS in InDesign at an exact position above the Hyperlink in a special layer (this will come handy later on).

                                                 

                                                And all that with ExtendScript!

                                                 

                                                In the next step we have to ask some questions to the InDesign document:


                                                1. Are there any form elements (or other interactive elements) inside that should be rendered to Acrobat forms and PDF interactive objects?

                                                 

                                                If so: export the PDF to Adobe PDF (Interactive).

                                                 

                                                Then, of course, all EPS files with our PDFmarks are rendered invalid.

                                                 

                                                2. To get out of this problem, we could do another thing:
                                                2.1 Set all layers but the one layer with the EPSs to "hidden", print to PostScript, make a PDF with Distiller and:

                                                 

                                                2.2 Layer the new PDF together with the exported PDF in Acrobat Pro.
                                                Then the two worlds are combined!

                                                 

                                                I'm sure #2.2 can be scripted as well. But now in JavaScript for Acrobat, which is a totally different beast compared to ExtendScript. At least in my eyes… ;-)

                                                 

                                                If you ask me:

                                                a lot of trouble for a tiny feature like opening a link in a different window in the browser.

                                                 

                                                Uwe

                                                • 21. Re: specify target in URLs for buttons or hyperlink settings
                                                  juliecracker Level 1

                                                  Uwe - thanks so much for the detailed explanation - I hadn't quite fully understood the 2 layer part of the solution, which now make sense (although I don't quite see how Maureen's solution worked).

                                                   

                                                  Thanks, too, for the confirmation that it is a lot more trouble than it's worth! (The bottomline for us is that we're trying to use a PDF created in InDesign as a web page, since we have more control over it, but really what our project needs is a web page.)

                                                   

                                                  julie