Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Opening encrypted attachment using Acrobat JavaScript exportDataObject

Avatar

Level 1

Hello Folks,

We are trying to implement an open button in our main pdf file, which tries to open an encrypted attachment in the pdf doc. The attachment is also a pdf document. Below is the code that we are using :-

var doc = event.target;

var dataObjects = doc.dataObjects;

var file;

var e;

var i;

for (i = 0; i < dataObjects.length; i++)

{

    file = dataObjects[i].name;

    try

    {

        doc.exportDataObject({ cName: file, nLaunch: 2, bAllowAuth:true  });

    }

    catch(e)

    {

        app.alert(e.message);

    }

}

This code works fine, when the user clicks open button, a dialog box opens asking for username and password, which tries to connect to the Rights Management Server and authenticates user. The authentication is derived by custom policies for each user on the Rights Management Server.

The problem is that if the user clicks cancel button on the login dialog box, then the box closes, and the control goes in the exception block, which is fine, but next time the user clicks on open button the control directly goes to the exception block, without opening the login dialog box.

And then the user has to close acrobat reader completly and open the file again to be able to click on open button and get the login dialog box.

I am open to implement any kind of Javascript solution, let me know if anyone has any pointers.

Thanks,

Amit.

3 Replies

Avatar

Former Community Member

I am speculating here but I think that the credentials are being cached and as you have not authenticated correctly the credentials are blank and that is what is being used the 2nd time. When the Reader is closed the cache gest cleared and hence it works the next time. Sounds like a bug to me. Have you opened an incident with Adobe Support?

Paul

Avatar

Level 1

That seems right to me. Is there a way to prevent that caching ? Like programatically or through configuration ?

One thing I forgot to mention, this does not happen on all the machines, on some machines, it works fine, I click on open, click on cancel, again click open and the box appears just fine. While on other machines, once I hit cancel on the login dialog box, the dialog box never appears again, the above code keeps going in the exception block.

So I am wondering if it is because of some setting in acrobat reader ?

Also, if its a caching issue, do you think that there could be a programmatic or configuration workaround this issue ? like cleanig all cache before attempting to open attachment ? or cleaning the whole acrobat temp directory ? or may be using some routine other than exportDataObject ?

I am asking this because the attachment section in the left side navigation buttons panel, built into Acrobat Reader works fine, I mean if I open the attachment from that section, and hit cancel on login dialog box, and try to open again, it just keeps opening fine. It fails only with the above code on some machines....

Thanks,

Amit.

Avatar

Former Community Member

I do not know of a way to prevent it .....thats why I suggested going through support. You say that it does not happen all of the time ...it might be tied to browser and OS and version of browser......can you track teh problem people and see if you can get a commonality amoungst them?

Paul