Highlighted

« closeDoc » and « This file is already open »

Participant ,
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, PDF forms

Views

67

Likes

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

« closeDoc » and « This file is already open »

Participant ,
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, PDF forms

Views

68

Likes

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

Copy link to clipboard

Copied

What version of Acrobat Pro?

Likes

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
Reply
Loading...
Participant ,
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.

@+

Likes

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
Reply
Loading...
Most Valuable Participant ,
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!

Likes

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
Reply
Loading...
Participant ,
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?

@+

Likes

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
Reply
Loading...
Adobe Community Professional ,
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?

Likes

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
Reply
Loading...
Participant ,
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...

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

What happens when you use not the same name?

Likes

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
Reply
Loading...
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Participant ,
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?

@+

Likes

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
Reply
Loading...
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF