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

Security error while importing text data

mlwallintx
Registered: Mar 30 2010
Posts: 17
Answered

I'm trying to import text data using the java script command importTextData, and I'm receiving a security error. I checked the item “Enable Menu Items JavaScript Execution Privileges” in Preferences. Is there something else I need to do?

Here's the code I put behind a button on the Acrobat form:

this.importTextData("C:\AcrobatImportTest.txt", 0)

Here's my error:

Acrobat JavaScript Debugger Functions Version 9.0
Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:1:Field cmdImport:Mouse Up

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:1:AcroForm:cmdImport:Annot1:MouseUp:Action1

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:1:AcroForm:cmdImport:Annot1:MouseUp:Action1

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:1:AcroForm:cmdImport:Annot1:MouseUp:Action1

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:1:AcroForm:cmdImport:Annot1:MouseUp:Action1

Here's my tab delimited text file:

UTMBMedicalRecord PatientName DateOfBirth
123456E "Jones, Bill" 12/7/1951

My Product Information:
Acrobat Pro 9.3.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
May it has to do with the following not in the JavaScirpt API under the 'importTextData()' method:

Quote:
[color=#FF0000]Note:[/color](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.
Or the format of your cPath parameter. You do not use Windows naming convention but you use Acrobats device-independent paths syntax.

Have you tried your code in the JavaScript console and what was the result?

If it works from the JS Console, then you need to incorporate it into an application folder level trusted function.

George Kaiser

mlwallintx
Registered: Mar 30 2010
Posts: 17
Thanks. I changed the syntax, and it did work from the Console window.

Where can I read about how to create an application folder level trusted function?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Thom Parker has written the tutorial article [url=http://www.acrobatusers.com/tutorials/2008/10/using_trusted_functions]Using Trusted Functions[/url].

George Kaiser

mlwallintx
Registered: Mar 30 2010
Posts: 17
That took care of it - I got it to work. Thanks!
mlwallintx
Registered: Mar 30 2010
Posts: 17
I was a bit premature in declaring this issue resolved. I did get the trusted function to work in Acrobat 9 Pro in my initial design. However, when I Extend Features in Adobe Reader, then open the form with 9 Pro or Reader, and click the button to run the trusted function I receive this error:

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:7:Field
ImportPtDemos:Mouse Up

So it doesn't work in either Reader or Pro after Extending Features in Reader.

Is there documentation somewhere that states which features will work or which won't work after Extending Features to Reader? I'd prefer not to take any more dead end paths!
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Have you installed the required application folder level scripts in the appropriate folder for Reader and on any end user systems?

George Kaiser

mlwallintx
Registered: Mar 30 2010
Posts: 17
I placed an identical folder level script in anther PC with Reader only. However, I also receive the error with Pro 9 when I run it on the same PC on which it was designed after Extending to Reader.

Here's my folder level script:

// import text function

ImportOneReferral = app.trustedFunction(
function(cPath, cRow)
{
app.beginPriv();
this.importTextData(cPath, cRow);
app.endPriv();
}
);


and here's the Javascript for the mouse up button action:

this.ImportOneReferral("/c/Data/AcrobatPtDemos.txt", 0);


I have nothing at the Document level that suppots this effort.

This is an Acrobat form - not Live Cycle. Does that matter?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
When one writes an application level function, one usually tries to keep it object independent for reasons of flexibility in programing and that the folder level function may lose sight of the object. So I would try including a parameter for the object to be processed.
// application folder level functionImportOneReferral = app.trustedFunction(function(oDoc, cPath, cRow){/*parameters:oDoc - document object to be processedcPath - full path to file to be importedcRow - row of file to be imported*/app.beginPriv();oDoc.importTextData(cPath, cRow);app.endPriv();});// end of application folder level function

Your button code would the become:
this.ImportOneReferral(this, "/c/Data/AcrobatPtDemos.txt", 0);

George Kaiser

mlwallintx
Registered: Mar 30 2010
Posts: 17
I put in your changes as suggested. Works before Extending to Reader. Still receiving the same message after Extending to Reader and testing form on same PC.

NotAllowedError: Security settings prevent access to this property or method.
Doc.importTextData:7:Field ImportPtDemos:Mouse Up