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

importDataObject throws exception of function top_level

kiotsuke
Registered: Feb 27 2008
Posts: 10

I've searched and searched and have no idea why this is happening. I've tried to call the importDataObject method in several different ways and it always gives me this error message. Why doesn't it work for me?

Code:
var oDoc = event.target;
var sAttachObjName = "myDoc";
oDoc.importDataObject(sAttachObjName);

Error:
Exception in line 3 of function top_level, script Console:Exec
undefined

I'm using Adobe Acrobat Professional for Mac. I'm new to both Adobe Forms and Javascript, and hope this is just some small thing that I'm missing. Please let me know if there is any further information needed.

Thanks!

My Product Information:
Acrobat Pro 8.1.1, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You are using LiveCycle scripting syntax. Since you are on a Mac, it's a good bet that you are not using a LiveCycle PDF.

Use regular Acrobat JavaScript syntax.
Try this.

this.importDataObject("MyName");

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
Thanks thomp!

Thats much better. But eventually I want users to be able to use this button to embed files into the form using Reader.

The browseForFileToSubmit method adds the path of the selected files, but does not seem to submit the file with the Form.

I've also tried to Enable User Rights, and Reader users are still unable to attach a file.

Is the answer to this to use an Adobe LiveCycle Policy Server? Can it be used from a Mac version of Acrobat Pro?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Embedding with Reader requires "Embedding" rights on the PDF. This Reader Extension Right and many others can only be applied with the LiveCycle ES Rights server. They are not included with the Rights that Acrobat 8 Pro can apply to a PDF.

The browseForFileToSubmit() function embeds the file into the submitted FDF data, or at least it's supposed to.

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
So basically a "no go" on a mac since LiveCycle isn't Mac friendly?

As for the browseForFileToSubmit() perhaps i've got something wrong with my submit and so forth. I've got the submit button set up for FDF, but when I publish it and open it with reader to try to fill it out. Reader saves a file with a .pdf extension after I go through the submit process. Shouldn't it be saving a file with a .fdf extension or something? I'm using an email submit because i don't have a online submit or local server submit set up.

Let me know if I need to give you more information, and thanks for all of your help so far.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The Rights enabling is done with the LiveCycle server for Rights enabling. This server is used to apply rights to all PDF files, not just those that were created with LiveCycle Designer. It's not clear from the product naming, but this isn't a MAC vs PC issue.

I gave the browseForFileToSubmit function a try and it worked fine, but with a twist.

I created a PDF with 2 buttons and a text field. The text field was set to file select. One button called browseForFileToSubmit() and the other button submited the form to an email.

To set up the file submit data, I clicked on the first button, which displays the file open dialog. I selected a plain text file that contained the words "Hello World". I then clicked the email submit button, which brought up my email client with new email and an FDF attachment. I saved the FDF attachment to a local folder and killed the email.

When I opened the FDF file it contained the selected file, but here's the twist. The file data was Flate encoded, so I couldn't see the "Hello World" text.
I'm pretty sure the FDF Toolkit could extract the unencoded data.

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
Thanks again Thom,

So conceivably, I'd be able to use LiveCycle server for Rights enabling? Is that some sort of subscription that I need to purchase?

The browseForFilesToSubmit still doesn't work for me. It might have something to do with the fact that Acrobat doesn't work with my default email client (thunderbird) so instead of opening my mail client when I click submit, I have to choose internet email or other and that saves a .pdf file not a .fdf file to my computer.

How do I get it to automatically save it as a FDF file? My submit button is set to FDF, is there something else i need to do to get it to behave properly?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The LiveCycle Servers are very expensive. But, at least for now, you may have an easy solution. Take a look on the Adobe Document Center. This is a free service from Adobe for trying out some of thier very expensive servers.

http://www.adobe.com/products/onlineservices/documentcenter/

If your submit button is set to FDF then Acrobat should be exporting FDF if everything is kosher with the email. Your email client seems to be a problem. You'll need to figure out how to get it registered with the system, or install another client to do your testing on.

I'm not familiar with how all this works on the Mac side. However, this can't be a new issue. I'm sure if you search on the older Acrobat User to User forums or Planet PDF you'll find posts that address exactly this problem, i.e. using an email client with Acrobat on the Mac.

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
I was using Thunderbird for Macs but switched over to Mail since Adobe seems to work with that better.

For some reason when I distribute the form it switches the .fdf submit button to a .pdf submit button. This is why it doesn't save an .fdf file for me. If I distribute it and open the email attachment in Acrobat the submit button is definitely a .pdf submit button. But if i don't distribute it and open the original form in Reader and fill it out and click submit it will save a .fdf file. However, when I save that file and open it in Acrobat I see the radio button and the normal text field just fine, but the filepath text field is blank and i don't see any attachments.

I do have the form set to enable user rights, if that helps.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ahh! The "Distribute Forms" feature in Acrobat automatically converts the submit to "PDF". This is to support the email data collection feature.

If you want to use the "browseFileToSubmit" functionality you can't use "Distribute Forms". You 'll have to email forms out yourself.

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
Ah ha! Ok, but even when I don't distribute the form, when i open the saved .fdf file with Acrobat there is no text in the filepath field (there was when i hit the submit button) and i have don't see anything about an attached file.

Do i need to view and compile the .fdf files with a different program? I'm sorry if I'm being a complete idiot about this.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Please try the demo I describe in my post on 3/4.

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

kiotsuke
Registered: Feb 27 2008
Posts: 10
Done, still same problem. When I open the saved .fdf file with Acrobat, I see the form but no file or filepath in the text field. Could this be a mac problem?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Don't open the saved file with Acrobat, open it with a plain text editor. The FDF file is not a PDF file, it's a data file. Mostly it contains name/value pairs for the submitted data. But it should also contain the submitted file. This file will be Flate encoded so you won't be able to see the content, but you will see the embedded file reference and the encoded bytes.

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