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

This file is already open.

New Here ,
Aug 24, 2018 Aug 24, 2018

Copy link to clipboard

Copied

@Thom Parker

The following code works well on previous acrobat revision, but now on acrobat DC doesn't work. Please give some help tips, thanks!

doc = app.openDoc({ cPath: "/C/temp/doc1.pdf" })
// List of files of different extensions
aFiles = new Array( "doc2.jpg ", "doc3.jpg ", "doc4.pdf");
for ( var i=0; i < aFiles.length; i++) {
// Open and convert the document
newDoc = app.openDoc({
oDoc: doc,
cPath: aFiles,
bUseConv: true
})
// Save the new PDF file to a temp folder
newDoc.saveAs({ cPath: "/C/temp/tmpDoc.pdf" });
// Close it without notice
newDoc.closeDoc(true);
// Now insert that PDF file just saved to the end of the first document
doc.insertPages ({
nPage: doc.numPages-1,
cPath: "/C/temp/tmpDoc.pdf",
nStart: 0
});
}

RaiseError: This file is already open.
Doc.saveAs:12:Console undefined:Exec
===> This file is already open.

undefined

TOPICS
Acrobat SDK and JavaScript , Windows

Views

246

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 ,
Aug 25, 2018 Aug 25, 2018

Copy link to clipboard

Copied

This happens because of a bug in Acrobat DC where the closeDoc method essentially doesn't do anything.

You should update the application to the latest version available, but I'm not sure it will solve it.

If it doesn't, you will need to work around it. For example, use a unique name for each temporary file, instead of the same one.

That way you won't have an issue with overwriting an open file, but you will only be able to process up to 50 files, as that's the maximum amount that Acrobat allows you to open at once.

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 ,
Aug 25, 2018 Aug 25, 2018

Copy link to clipboard

Copied

LATEST

Also: check whether openDoc returns NULL. Report this or ignore it, but don't try to continue with a nonexistent document object.

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