Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

JavaScript importDataObject in trusted JS functrion still generatesNotAllowedError

Community Beginner ,
Jan 19, 2024 Jan 19, 2024

Hi, 

Don't know if someone already experienced the issue. 

I used to add attachements to my pdf using the AddAnnot method in a trusted JS function, without issue. 

For convenience, I moved to the importDataObject , giving more flexibilities. Unfortunately, and whatever security option i set in the reader, the following code generates the error:

NotAllowedError: Security settings prevent access to this property or method.

var import_doc = app.trustedFunction ( function (c,doc) {
app.beginPriv();
doc.importDataObject(c);
app.endPriv();
}
);

Any help or advise will be more than welcome. 

Thanks 

Phil

TOPICS
JavaScript , Security digital signatures and esignatures
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2024 Jan 19, 2024

- Where did you place this code?

- How are you calling it?

- Where are you calling it from (what application and version)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2024 Jan 21, 2024

Hi, 

The code is part of all my secured developped functions and the JS is stored in the expected location: C:\Program Files\Adobe\Acrobat DC\Acrobat\Javascripts. For info, all the other secured functions work fine.

one call exemple I call it from a "mouse up" event in a check-box, in the "run javascript" section. : 

if(this.getField(event.target.name).value !== "Off") {
var c="CLO-"+event.target.name;
var doc="AccClosing"
console.println("Attaching file with name:"+c);
import_doc(c,this);

}
if(!checkAttached(c)){
app.alert("Atttaching a document is mandatory when this choice is selected");
this.getField(event.target.name).value="Off";
}

Error in the console: 

NotAllowedError: Security settings prevent access to this property or method.
Doc.importDataObject:161:Field CB1-LCL:Mouse Up

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024

This will only work in Acrobat. Reader can't attach files like this, only as an annotation.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 22, 2024 Jan 22, 2024

Oh, I see. Not documented anywhere. I supposed all the JS code could be run on any adobe platforms and compatible. This is the first time I'm facing an incompatibility between products. 

I used to use the annotations before, but found the importDataObject much more flexible. Thanks anyway for your time to answer.

Best. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024

It is documented in the JS API Reference, with the symbols under the method's name, but I agree it's not very clearly stated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 22, 2024 Jan 22, 2024

In the API doc i'm working with, the info is not so clear: Doc and Doc.Media APIs — Acrobat-PDFL SDK: JavaScript Reference (adobe.com)

please see abstract attached. 2024-01-22 15_02_10-Doc and Doc.Media APIs — Acrobat-PDFL SDK_ JavaScript Reference et 12 pages de p.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024

See the specification of the "D" value under Save-Prefs, here:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html#table-quick-key

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 22, 2024 Jan 22, 2024

I see indeed this was not obious! Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2024 Jan 19, 2024

And, 

What security options have you tried?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2024 Jan 21, 2024

The application is Adobe Acrobat Reader (see details attached)

2024-01-22 08_38_10-.pngexpand image

2024-01-22 08_35_33-Preferences.pngexpand image2024-01-22 08_34_57-Preferences.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024

This error message is misleading and the documentation is inaccurate.

You must go back to the addAnnot method because importDataObject is not supported by Acrobat Reader (Pro and Standard only).


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 22, 2024 Jan 22, 2024

Thanks JR. My issue with the annots attachments is to be able to work with the attached file in a second phase. I need to open the attached file and get some info from it. Unfortunately I'm unable to find all the properties of the attachment object from a FileAttachment type annot. In addition, the documentation seems to say the attachment object type is a dataobject, but I cannot access it really as a dataobject. Do you have any clue how to achieve my goal? 

thank you in advance. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024
LATEST

What kind of property do you need to find?

Try this in the JS Console:

for (var i=0; i<this.dataObjects.length; i++)
{console.println("Attachment #"+i+": " +this.dataObjects[i].name);}

Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines