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

Is it possible to use the openDoc method to open a attached file (embedded)

PDFchild
Registered: Oct 31 2010
Posts: 44
Answered

Hello,
 
I want to set a JavaScript button to open an "attached" PDF file. I have used the openDoc function before but never used it for opening attached files.
 
I have tried the script which I copied from the following page:
 
http://acrobatusers.com/forum/forms-livecycle-designer/open-pdf-which-be-attached-pdf
 
But no success. Please help.
 
One other thing I wanted to ask; Is it possible to use openDoc at the document level so that the attached file opens whenever the parent file is launched?
  
thank you

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

My Product Information:
Acrobat, Windows
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
For attachments you use the doc.exportDataObject() method - which will work just fine at the document level.
PDFchild
Registered: Oct 31 2010
Posts: 44
many thanks for the quick reply!!

I have used this at document level.

this.exportDataObject({ cName: "TEST.pdf", nLaunch: 2 });



But when I open the PDF in reader I get:

There was an error....invalid action object.

Please help.

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

PDFchild
Registered: Oct 31 2010
Posts: 44
I have read the Acrobat JS reference. It says the openDataObject is the right method to do it.

So I tried:

this.openDataObject("TEST.pdf"); or this.openDataObject({ cName: "TEST.pdf" });

both of them are not working

BTW my attached file name is TEST.pdf

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

PDFchild
Registered: Oct 31 2010
Posts: 44
...

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

try67
Expert
Registered: Oct 30 2008
Posts: 2398
The name of the file is not necessarily the same as the internal name used for the attachment.
You can use the dataObjects property of the document to print out all the names of the attachments in your file.
Or if you know there's only one data object, you can simply execute:
this.openDataObject(this.dataObjects[0].name);

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

PDFchild
Registered: Oct 31 2010
Posts: 44
Thanks for the reply Try67,

but I think I am doing something very wrong. Can't make it work :'(


I have made a simple version of the situation.

http://www.mediafire.com/?e19g8bim6qdklzy (PDF 15kb only)

Its not coded. Can you a use a working code of openDataObject?? so that I may figure out what went wrong.

Many thanks

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

try67
Expert
Registered: Oct 30 2008
Posts: 2398
I've tried it using the code I've provided... The file is being opened, but it is hidden, and my attempts to unhide it (by setting its hidden property to false) have failed.

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

PDFchild
Registered: Oct 31 2010
Posts: 44
Many Thanks for looking into this, can you post a sample file instead?

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Accepted Answer
Hi,

here is your fully coded sample file: http://abracadabrapdf.net/parking/AcroUsers/PARENT_PDF_OK.pdf

;-)
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
PDFchild wrote:
Go Green Save Paper Adopt a PDF
--> http://www.saveaswwf.com/en/

:-))
PDFchild
Registered: Oct 31 2010
Posts: 44
Merlin wrote:
PDFchild wrote:
Go Green Save Paper Adopt a PDF
--> http://www.saveaswwf.com/en/:-))
VERY INTERESTING!!!

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Fine!

But… what about PARENT_PDF_OK.pdf ???


PDFchild
Registered: Oct 31 2010
Posts: 44
Hello Merlin,

It works!! That is one cool PDF!

BTW I had sent you a mail/PM regarding this on 2011-10-08. Did you get it?

Thank you.

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

PDFchild
Registered: Oct 31 2010
Posts: 44
Merlin wrote:
Fine!But… what about PARENT_PDF_OK.pdf ???
Hello Merlin,

It works!! That is one cool PDF!

BTW I had sent you a mail/PM regarding this on 2011-10-08. Did you get it?

Thank you.

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

rbogie
Registered: Apr 28 2008
Posts: 432
MUCH APPRECIATED!!
the 'attach file as comments' icons are all but useless.
you provided the solution.