These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

PDF embedded in HTML: Targeting links in PDF to a new browser window

Run Free
Registered: Jul 18 2009
Posts: 11
Answered

Hi,
I posted a couple of times looking for a solution to this challenge:
I have a large (293 page) PDF. We will display pages of the PDF within an HTML page that is part of our Web-based application. The PDF contains many links to many different websites/pages. By default, when you click a link in the PDF, the destination site opens in the same browser window as our container HTML page, effectively taking the visitor off of our site/application.

I wanted to find a way to force the link to open the corresponding destination site in a new browser window. Through Googling, I discovered app.launchURL. However, with so many links in our PDF, I was loathe to begin tackling customizing each of them. Is there a way (batch/macro/action) to globally change/customize all of the links in our PDF, so that they all trigger the new window behavior, caused by app.launchURL...'true'?

Well, I never did get a solution. So, I tackled the manual approach. Using the process I worked out below, I was able to fly through the document pretty quickly. It seems that someone who was really good with JavaScript might be able to come up with a script to do this, with the URL as a variable?
Anyway, here's how I got through it (looks worse than it was; I was just trying to be complete here)...oh, using Acrobat Pro 8.1.2 here...

1. Open the PDF. (As we discovered, creating the PDF from within Acrobat, using the ‘Create PDF’ command, results in the links you embedded within your source Word file being ‘editable’ in Acrobat after the PDF is generated. That is, versus when you create the PDF by doing File/Print/PDF from within Word—when you use that method, you cannot use Acrobat’s Link tool to edit the links.)
2. Display the ‘Advanced Editing’ toolbar.
3. Select the ‘Link’ tool. All of the links in the PDF are outlined with a rectangle.
4. Right-click any link and select Edit/Select All. All of the links in the PDF are now selected.
5. Right-click any link and select ‘Properties.’
6. Click the ‘Actions’ tab.
7. The ‘Open a web link’ action should be listed. That’s the default action for all links in your PDF. The URL displayed for the action of course varies with the link.
8. In the ‘Actions’ list in the bottom portion of the dialog, highlight the ‘Open a web link’ line and click ‘Delete.’
9. Click ‘OK.’ Since all links in the PDF were selected, the corresponding ‘Open a web link’ action is now gone for each of them.
10. Now, repeat steps 4., 5. , and 6. to select all of the links and open the Properties dialog, with the Actions tab selected.
11. Select ‘Run a JavaScript’ from the ‘Select Action’ drop list.
12. Click ‘Add.’
13. Enter this bit in the open JavaScript Editor dialog.
app.launchURL("http://", true); (This is key--notice that there is no URL except for the opening ‘http://’ between the open and close quotes)
Since all links in the PDF were selected, this JavaScript action has now been applied to each of them.
14. Go to the first link in the PDF.
15. On the Advanced Editing toolbar, select the TouchUp Text tool.
16. Highlight all of the URL following ‘http://’ and press CTRL+C to copy it.
17. Select the Link tool.
18. Right click the link and select Properties.
19. Click the Action tab.
20. Click ‘Edit’ below the ‘Actions’ area. (The ‘Run a JavaScript’ action should be all that is listed.)
21. Paste the URL bit from the clipboard, immediately following the ‘http://’ and before the ending quote in the script.
22. Click OK.
23. Go to the next link and repeat steps 15. through 22.
24. Continue on through the document, saving frequently.
Be sure to glance at the script as you paste…watching to make sure to take out extra space, periods, or commas you might have picked up when copying the URL.

My Product Information:
Acrobat Pro 8.1.2, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
I think there is no way to do this.
Links to URL's that have been automatically been generated through acrobat (advanced > document processing > Create Links from URLs) passing a acrobat plug-in called weblink driver.
These links then are hardcoded into the pdf (you can only read them out with a hex editor not via JavaScipt).
The weblink driver does not provide any function to open links a new window.
If there is just a browser window opened, it will choose this one.
So the way you do now, seems to be the only one.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Run Free
Registered: Jul 18 2009
Posts: 11
Thank you radzmar. After doing all the work manually, I was almost relieved to see your confirmation here, versus..."oh, you didn't need to do all that work; here's a handy way to apply the targeting globally, all at once."
:-)