Skip to main content
dublove
Legend
October 5, 2026
Question

How to determine if a PDF with the same name at the current location is open?

  • October 5, 2026
  • 4 replies
  • 42 views

I export a PDF using the following statement, but sometimes there are exceptions. Later, I found out that a PDF with the same location and name is open.

Like this:

var myPDFFile = new File(desktopPath + "/" + exPDFname + "/" + getpRange + ".pdf");
//if (myPDFFile.isOpen) {
// alert('Please close the PDF with the same name first');
//}
myDocument.exportFile(ExportFormat.PDF_TYPE, myPDFFile, false, preSle);

Or more scientifically:
Automatically close the 'myPDFFile' currently open in Acrobat.

    4 replies

    rob day
    Community Expert
    Community Expert
    October 5, 2026

    Automatically close the 'myPDFFile' currently open in Acrobat.

     

    I don’t think you can do it. BridgeTalk is the way to communicate between Adobe apps, but there is no BridgeTalk/ExtendScript support for Acrobat. On MacOS it could be done via Applescript 

    dublove
    dubloveAuthor
    Legend
    October 5, 2026

    It doesn't have to be confirmed that it was opened by Acrobat.
    If it can know that the file is currently occupied and a prompt pops up, I can also manually close it.

    rob day
    Community Expert
    Community Expert
    October 5, 2026

    I don’t see a way. You can look at the File object methods, but that wouldn’t tell you if a PDF with the same name as the one you are exporting is currently open.

     

    https://www.indesignjs.de/indesignapi/javascript/File.html