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

Extract data only into a file in PC

tpcheng
Registered: Mar 22 2009
Posts: 16

Hi All,

I need to write my first eForm using LiveCycle Designer. The requirement required to extract user's input data only and then store into a file which is located in local PC. How can I do that?

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Do you want the user to be able to export data from the form to a local file? or is this something that only the form administrator will be doing?

The is no direct way for code on the form to write to a local file. Especially if the form is being displayed in Reader. It can be done, but in this case the user is prompted for the filename and save location.

You can write Acrobat automation code (a folder level script) that will silently export data to a local file with an automatically generated name.

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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
The requirment is to make a button, allow the user to click so that the data inputted by the user was checked and then saved and export the data to a local file.

A folder level script? How can I do that? Any suggestion?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
A folder level script is a JavaScript file that has to be installed on the users system. Special privileges come with being installed on the system, as opposed to a PDF script, which is inside the PDF documents. Scripts in documents are restricted.

Look in the Acrobat JavaScript Reference for the "doc.exportAs..." functions. These functions can be used from either context, Folder Level or PDF Script. But for a PDF Script, the function will always ask the user for the file save location.

These fucntions can also be used in Reader, but the PDF file has to be Rights Enabled for "Save".

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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
I have tried xfa.host.exportData("",0) and it works when I tested in on Livecycle Designer.
However, there is no reponse when I try it on Adobe Reader.
Any settings is/are required?
Many thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Did you "Rights" enable the PDF for Reader??

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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
1) I have also tried event.target.exportAsText({cPath: "/c/temp/test.txt"});
but there is no response on both LC and Reader. Any hints?

2) How to 'Rights' enable the PDF for reader?

Many many thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Open the PDF file in Acrobat Professional 8 or 9. The select the "Advanced > Enable Usage Rights in Adobe Reader" menu item.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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
Just tried. But no response. I am using Acrobat Professional 8.0
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Are you saying that you selected the "Advanced > Enable Usage Rights in Adobe Reader" menu item and nothing happened?? Nothing at all??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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
A message box pop-up saying that
'The following features will become available for this document when opened in the free Adobe Reader.
-Save form data (for a fillable PDF form only)
-Commenting and drawing mark-up tools
-Sign an existing signature field
-Digitally sign the document anywhere on the page (only supported in Adobe Reader 8.0)'

However, the 'xfa.host.exportData' function still doesn't work.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, please check the JavaScript Console Window to see if any errors were reported. In your case you should see a security violation.

Ok then, you have completed the first bit. Now that the document is Reader Enabled with Save Rights you can export data using a script. However there is another piece. Again, in the Acrobat JavaScript Reference, notice that all of the Export functions have a Red "S" in the 3rd column of the Rights Bar. And in the Red "Note" it states that if the "cPath" parameter is specified the function can only be run from a "Privileged" Context. This is why the export function is throwing a security violation. So you have to call the export without a path.

Try this code in the Button:

event.target.exportXFAData({bXDP:false});

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

tpcheng
Registered: Mar 22 2009
Posts: 16
I tried the code and selected "Advanced > Enable Usage Rights in Adobe Reader".
But the following error exist when I test the form in Reader
'NotAllowedError: Security settings prevent access to this property or method.
Doc.exportXFAData:1:XFA:topmostSubform[0]:Page1[0]:Button1[0]:click'

Same error as the code 'xfa.host.exportData'.

Is it a must to buy a Reader Extensions license in this case?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I've looked over the documentation and what I've told you is correct as far as the JavaScript Reference goes.

But I did some testing and I am getting the same results you are. I placed an export button on a LiveCycle form, then Reader Enabled that form with Acrobat 8 Professional. I tried the document on Reader 7, 8, and 9. All reported the same Not Allowed Security violation :*(

The only conclusion I can come to is that the Rights Applied by Acrobat Professional are insufficient. I appologize for my previous answers. I now believe you are correct in that to make this work, additional Reader Rights will need to be purchased from Adobe, specifically "Export" rights.

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]

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

tpcheng
Registered: Mar 22 2009
Posts: 16
Thom,

No need to apologize. I appreciate your kindly help. Thank you very much.