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

JavaScript Auto Fill code not working in Adobe 8

LMPIPER
Registered: Apr 4 2007
Posts: 16
Answered

We do what we call Auto Fills. These are Adobe documents that when brought up from our web site will automatically fill in some data from files stored on the user’s computers.
This is done with the script shown below. These have been working for the past 3 years
With Adobe 5, 6 & 7. Some of our users have started getting Adobe 8 and the script no longer works. There must be some Adobe 8 secret I am missing to change or add to the script to allow the documents to work with Adobe 8.

//
//StartMe
//
/*********** belongs to: Document-Level:StartMe ***********/
function StartMe()
{
DataPath = "C:\\seid.dat";
importTextData(DataPath,0);
var Seid = this.getField("seid");
var Seidv = Seid.value;
DataPath = "D:\\users\\"+Seidv+"\\SBU data\\Form9856.dat";
importTextData(DataPath,0);

var DataPath ;

DataPath = "C:\\Documents and Settings\\"+Seidv+"\\SBU\\Stop.dat";
importTextData(DataPath, 0);
DataPath = "C:\\Documents and Settings\\"+Seidv+"\\SBU\\IDRSnumber.dat";
importTextData(DataPath, 0);
var d = new Date();
this.getField("date").value = (d.getMonth()+1).toString()+"/"+d.getDate().toString()+"/"+d.getFullYear();
}
//
//

//
//Page1:Page Open:Action2
//
/*********** belongs to: Page-Actions:Page1:Page Open:Action2 ***********/
StartMe();
//
//

Thanks in advance for your help.

Leo

My Product Information:
Acrobat 3D 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
What is the error message that is being thrown?

This message will appear in the JavaScript debugging console.

Sounds like you have been caught by Adobe changing the order in which a document and page are initialized. Your page open script may be running before the document initialization script is run. Causing the "StartMe()" function to be undefined. If this script is to be run one at initialization there is nothing stopping one from placing the call right after the definition of the function.

George Kaiser

LMPIPER
Registered: Apr 4 2007
Posts: 16
Thanks for your reply.

Following is the error message shown on the JavaScript debugging console:

"NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:4:Page undefined:Open"


Unfortunately I have no idea as to what adobe 8 wants me to do to allow this auto fill.


Yours hopefully

Leo
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Version 8 has added the following security restriction in Version 8:

"Note: (Acrobat 8.0) If cPath is specified, this method can only be executed during batch and console events. See “Privileged versus non-privileged context” on page 32 for details. The event object contains a discussion of JavaScript events."

Because you are specifying a path, you need to use the privleged context in a trusted function. All this code will be placed in a folder level Acrobat/Reader application JavaScript folder or the form will required "certification" for the code to be used.

This will also require some code that will not call this special code for versions prior to version 8.

George Kaiser

LMPIPER
Registered: Apr 4 2007
Posts: 16
Sorry for being so thick headed but just what manual are you referring to. I apparently don’t have any that address “Privileged versus non-privileged context on page 32”

Thanks again for all your help.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Sorry, the JavaScript for Acrobat API Reference, version 8 available form http://www.adobe.com/devnet/acrobat/javascript.php JavaScript for Acrobat.

You also might want to look at the http://www.adobe.com/devnet/acrobat/ Acrobat Developer Center and the SDK documentation.

George Kaiser

LMPIPER
Registered: Apr 4 2007
Posts: 16
Thanks for your help. My document now works with Adobe 8 & 7.1. My users have 5, 6, 7, (7.0 & 7.1) & 8. I am now looking into how to make the doc work on the older levels.Thanks again.

Leo