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

« closeDoc » and « This file is already open »

Community Expert ,
Jul 13, 2020 Jul 13, 2020

To avoid creating temporary files that would then have to be deleted, I usually name them with the final file name and rewrite it.

Maybe it's a bad habit, but I didn’t find any other solutions.

My question is, when I do this in an action or through the console with a single script, I get an error message that tells me that the file is already open.

If I split the action into 2 consecutive scripts, that works fine.

Is there a reason and a way to solve this? I guess that comes from « closeDoc » and the file is supposed to be still open…

Here is an example of a script which works fine in 2 separate scripts, but which gives the message if it is executed in one go:

// Script #1
var newDoc=app.newDoc(612, 792); // Letter
newDoc.saveAs({cPath: this.path.substring(0,this.path.length-4)+"_XXX.pdf"});
newDoc.closeDoc(true);
// Script #2
var newDoc=app.newDoc(612, 1008); // Legal
newDoc.saveAs({cPath: this.path.substring(0,this.path.length-4)+"_XXX.pdf"});

…and the message:

RaiseError: Ce fichier est déjà ouvert.

Doc.saveAs:7:Console undefined:Exec

 ===> Ce fichier est déjà ouvert.

 

« Ce fichier est déjà ouvert » means « This file is already open »

Thanks in advance for your answers.

@+

TOPICS
Acrobat SDK and JavaScript
1.2K
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 ,
Jul 13, 2020 Jul 13, 2020

What version of Acrobat Pro?

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 ,
Jul 13, 2020 Jul 13, 2020

I am working with Acrobat Pro 2019.021 Mac but that was already the same in the previous versions.

@+

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
LEGEND ,
Jul 13, 2020 Jul 13, 2020

It's an Acrobat bug (files closed aren't really closed) which Adobe don't seem interested in fixing for some reason. So best to avoid this bad habit!

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 ,
Jul 13, 2020 Jul 13, 2020

OK, thanks.
Just for my understanding, do you know what's happening on at the end of each script since that works with consecutive scripts? I guess a type of variable is reset... isn't it possible to do that with the script?

@+

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 ,
Jul 13, 2020 Jul 13, 2020

May be that the Action Wizard will close the documents at the end step.

 

Why does you create files with the same name 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 Expert ,
Jul 13, 2020 Jul 13, 2020

it's a bit long to explain, but quickly these are temporary files I resize to re-import then in the current file I'm working with...

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 ,
Jul 13, 2020 Jul 13, 2020
LATEST

What happens when you use not the same name?

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 ,
Jul 13, 2020 Jul 13, 2020

This is a bug that has existed in all versions of Acrobat past XI, for a long time now... Adobe doesn't seem interested in solving it, for some reason. It really interferes with the working of many scripts.

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 ,
Jul 13, 2020 Jul 13, 2020

Thanks try67!

...and no idea about what's happening at the end of each script (or mabe at the beginning) since that works in 2 consecutive scripts?

@+

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 ,
Jul 13, 2020 Jul 13, 2020

Not quite sure what you mean... but if you're using it in an Action it will automatically close any file it processes, but not other files you create (or open) using a script.

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