1
votes

I'm having a problem with closing Acrobat. I'm using vb.net to sign a PDF file in running Acrobat. After I'm done I close Acrobat and try to delete the currently signed PDF file, but I get an error message telling me that file is being used by another process. I tried closing and setting to Nothing AcroApp, AcroAVDoc, AcroPDDoc JSO, but still that doesn't work. I tried releasing them with Marshal.ReleaseComObject(...) still no effect.

        acroPDDoc.Close()
        acrobatAVDoc.Close(False)
        acrobatApp.Exit()

        Try
            Marshal.ReleaseComObject(javaScriptObj)
        Catch ex As Exception
        End Try

        Try
            Marshal.ReleaseComObject(acroPDDoc)
        Catch ex As Exception
        End Try

        Try
            Marshal.ReleaseComObject(acrobatAVDoc)
        Catch ex As Exception
        End Try

        Try
            Marshal.ReleaseComObject(acrobatApp)
        Catch ex As Exception
        End Try

        javaScriptObj = Nothing
        acroPDDoc = Nothing
        acrobatAVDoc = Nothing
        acrobatApp = Nothing

The alternative below that I do not want to use because it will kill all open PDF documents which I do not want.

'Gets All Acrobat Processes
Dim tProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Acrobat")

'Kills Each Acrobat Process
For Each AcrobatProcess As Process In tProcess
    AcrobatProcess.Kill()
Next

Please help me find a way around this. Thanks

2
Have you tried waiting for a few seconds as somtimes the lock lingers - rerun
yeah waiting doesn't help. It just hangs there. - Pavel P
As you didn't post code that shows how you "tried closing and setting to Nothing", how exactly do you expect us to help you determine why it didn't work properly? - Ken White
I have edited my post and added the close code - Pavel P

2 Answers

2
votes

I came up with a solution similar to this. You can look at my example (the link below), and it may help your situation. Record all open acrobat docs, then kill, and re-open them up. The user can then close each doc manually without Acrobat ever hanging. It may not be the best solution, but its a workable one.

VB.Net / Acrobat - Acrobat hangs after user manually exits program

0
votes

Verify that all objects are released. I had the same issue with a utility written in C# that merged pdfs using the PDDoc InsertPages method and added bookmarks through the JSObject interface.

I found that I once I released the object storing my bookmarkRoot that the Acrobat.exe process would free up once the last object was released. I did not have to kill the process.