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

open document with javascript

lecochon
Registered: Feb 22 2010
Posts: 8

I have a pdf file that uses Javascript to find the file path and then open another pdf document in another folder. It works fine until I place the files into a portfolio. All the files remain in the same positions relative to each other but the second file will no longer open. When I look at the path, the portfolio adds some funky characters to the path.

Should I still be using the app.opendoc command within a portfolio? If so, what do I need to do differently in regards to the path?

Thank you for your help.

My Product Information:
Acrobat Pro 9.0, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Files inside a Portfolio are not files in a disk folder. They cannot be opened with JavaScript in the same way. These files are actually PDF attachments. The Portfolio is just a fancy way of putting a fancy looking user interface over the attachments. In JavaScript you can see these files with the "doc.dataObjects" property and open them with the "doc.exportDataObject()" function.

However, the idea with a portfolio is that you'll be using ActionScript from the Navigator to open the files, since this is the front end.

From where was your original code run? Was it in a PDF or a Folder level script?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

lecochon
Registered: Feb 22 2010
Posts: 8
Thanks for the quick response. The original code was just a document-level script. Besides not working, it also generated a security error message. Are document-level javascripts allowed to open files within a portfolio?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Scripts work just fine in a Portfolio. However, app.openDoc() will throw a security exception if the path to the file is not correct. It will do this in any context. It looks like a not allowed error, but it's really a bad file path error.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

lecochon
Registered: Feb 22 2010
Posts: 8
Sorry if I'm being obtuse, but I still can't seem to navigate from one file in a portfolio to another using the doc.exportDataObject() function. Where does the script need to be placed?

Do you know of any javascript examples of intra-portfolio navigation?

If I eventually distribute this, will people be able to view this with Reader, or will the doc.exportDataObject() function cause security problems?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I think I get where you are going. You want to navigate from a document inside a portfolio to another document inside the portfolio (it's good to explicitly state these things). The exportDataObject function only operates from the file that contains the data objects(file attachements). In a portfolio this is the cover page. Which you can't normally see because the navigator covers it up.

It would be really cool if the Portfolio looked file file system to JavaScript environment. You could do all kinds of great things with this. Its frustrating the Adobe missed such an obvious and useful feature. But no, the files inside the portfolio all operate in thier own independant document environments. The JavaScript world inside the attached PDF has absolutely no idea that it is inside a portfolio, so it has no way of knowing about any of the other files in the portfolio.

To perform this type of navigation requires special setup code in the cover sheet PDF that sets up special code in the embedded files so they can recognize that they are in side a portfolio. I have a theory about how this could be done but it's a lot of work and I don't even know if it will work. So the short answer is that it can't be done. The Portfolios are designed so that the user has to use the Portfolio controls to get to another file.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

lecochon
Registered: Feb 22 2010
Posts: 8
Thanks. No wonder I couldn't couldn't get that to work.

My portfolio contains several thousand pdf documents that need to be interlinked. I will know the directory structure ahead of time. The problem is that I need to have 17 different versions. Some will contain all of the documents, others will only contain a portion of the documents. And every year I will have to update all 17 versions and add a number of documents to each portfolio.

If I manually set a link from one file to a page view in another file in the same portfolio, it works fine. So Acrobat can handle the navigation and it can remember the path from one file to another. Is there any way to use Javascript to create or modify a link like this instead of creating them manually?

If not, I don't mind creating the links manually once, if I have to. But I'd like to avoid redoing it 17 times every year. If I created the links manually, is there a way for me to use a Javascript function on one page to execute a link on another page in the same document?

Thanks for your help.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The links you create inside a portfolio, from PDF to PDF use what's called a GoToE Action, or a Goto embedded file. These cannot be set or controlled from JavaSript and as far as I know Acrobat does not have any automatic facility for converting these links when the Portfolio is built.

But you never know, there may be a 3rd party product that does this conversion. It'd certainly be useful for these kinds of document setups. I've talked to lots of people who use groups of PDFs and/or PDF libraries and have looked at Portfolios as a way to consolidate information. But ultimately give up because Portfolios are very limited. For example, you can build a serach index file for a library on CD, but you can't for files in a Portfolio. There are all kinds of issues like yours. I'm supprised you even got a Portfolio with several thousand files to load.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script