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

« closeDoc » and « This file is already open »

Community Expert ,
Jul 13, 2020 Jul 13, 2020

Copy link to clipboard

Copied

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

Views

753

Translate

Translate

Report

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

Copy link to clipboard

Copied

What version of Acrobat Pro?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

@+

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

@+

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

Why does you create files with the same name twice?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

What happens when you use not the same name?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

@+

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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