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

Opening same file twice in Javascript not working

Community Beginner ,
May 25, 2020 May 25, 2020

I wish to open and close the same file while running a javascript, but in second attempt to open file, it does not open, the program stops running and no error message is generated.  Opening and closing the same file works in Adobe Pro 9.3 but not Reader DC version 2020.009.20065. I am ruuning Windows 10, version 1909. This code works in previous versions of  Reader.

 

Below is an example showing "SampleDoc.pdf" being opened and closed.

 

==========================================

var otherDoc = app.openDoc("SampleDoc.pdf", this);

//(program code not shown)

otherDoc.closeDoc(true);

 

//(program code not shown)

 

var otherDoc = app.openDoc("SampleDoc.pdf", this);

//(program code not shown)

otherDoc.closeDoc(true);

==========================================

 

 

Within Reader DC,

Javascript: Javascript: Enabled Acrobat JavaScript and JavaScript Debugger: Show console on errors and messages, are checked.

Security (Enhanced): Sandbox Protections: Enable Protected Mode at startup and Enhanced Security: Enable Enhanced Secuirty is not checked.

 

I have "this.disclosed = true;" at the document level.

 

In the Javacript folder within Reader DC and Adobe Pro 9.3, I added two JavaScript files:

 

0_SafeDataObjects, which contains the code:

myExportDataObject = app.trustPropagatorFunction(function(doc,name){

app.beginPriv();

            doc.exportDataObject({cName: name});

app.endPriv();

})

myTrustedExportDataObject = app.trustedFunction(function(doc,name) {

app.beginPriv();

            myExportDataObject(doc,name);

app.endPriv(); 

});

 

var myImportDataObject = app.trustedFunction(

function(doc,name,path){

app.beginPriv();

doc.importDataObject({cName: name, cDIPath: path});

app.endPriv();

})

 

var myGetPath = app.trustedFunction(

function(category, folder){

app.beginPriv();

return app.getPath(category, folder);

app.endPriv();

})

 

 

and, safeSave, which contains the code:

var safeSave = app.trustedFunction (

    function(doc)

    {

        app.beginPriv();

        doc.saveAs({cPath:doc.path});

        app.endPriv();

    }

);

TOPICS
PDF forms
672
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 ,
May 26, 2020 May 26, 2020

There's a bug in Acrobat (and Reader) DC that prevents the closeDoc method from working, unfortunately.

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 ,
May 26, 2020 May 26, 2020

Without rewritting over a 1,000 documents, is there a work around, that can be inserted in 0_SafeDataObjects or safeSave javascript files?

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 ,
May 26, 2020 May 26, 2020
LATEST

Not that I'm aware of.

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 ,
May 26, 2020 May 26, 2020

Why want you open the same document twice?

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 ,
May 26, 2020 May 26, 2020

I've coded more than 1,700 documents, some of which required the same file to be opened. The sample code I provided was a condencedversion of documents being linked together as required.

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