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

Using JavaScript to open a link from a PDF file...

Joel
Registered: Dec 12 2007
Posts: 3

How would I use JS to open a link, from within a PDF file, into a new window that would have a specified Height and Width?

Here is my dilemma... I have a list of names and phone numbers that is in a PDF document. The list also has a link next to the name that reads "View Photo".

I would like to be able to click on that link and have a new window pop-up that displays the photo but within a window that is only slightly larger than the photo itself. For example, if the photo is 300x400... I would only want the window to be, say, 315x420. Note: all the photos are the same dimensions... so there will be no need for dynamic coding based on the size of the photo - the height and width of the window can be static.

Any help with this would be greatly appreciated.

Joel

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
What type of new window do you want to link to from the PDF? Browser, file system, Acrobat dialog pop-up?

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

Joel
Registered: Dec 12 2007
Posts: 3
I would want to open them in a browser window... but would it be easier to open it in a Acrobat dialog pop-up?
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
You might have more control over the size if you do a popup but it's more complicated.
For a browser you can use this Javascript to open a URL link in another window:
app.launchURL(“http://www.adobe.com/file.pdf”, true);
By default, a URL link opens in the same window if the browser is open and displays a web page.

If you want to try a pop-up check out Thom Parker's examples on this at:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/popup_windows_part1/

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

khichar.anil
Registered: Sep 28 2011
Posts: 1
Hi lkassuba,

PDF java-script seems not working on mac browsers. I tried mac+FF & mac+Safari.
In my case, i have one pdf form having submit button. I need to submit the form data over server and then there will be response from the server.
Even java-script's app.alert("msg"); is not working on mac. Though java-script works when it's open in pdf reader on mac.
My requirement is to open the pdf within the browser. All the stuff works well on windows on all the browsers.

Could you please help me why not pdf java-script works on mac browsers ?

Thanks!
Anil
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Are you viewing the file in Adobe Reader or in Apple's Preview? If the latter, the you need to contact Apple about that.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com