1

We have a Winforms application that uses PDFViewer and AxAcroPDFlib. We previously had a problem where the form would hang when closing because the pdf control was having trouble closing. The solution, found here, was to assign focus to a different control during the forms closing event. This has worked with no problems since implementing.

This past week there was an update to Adobe Reader DC and the problem seems to have returned. There is a delay in closing the form again. When closing the form an Adobe Acrobat icon appears on the task bar for about 10 seconds, then disappears and the form closes. This is what happened before.

Does anyone have any idea how to correct this problem now?

I'd like to replace this control with another that doesn't rely on the user having Acrobat installed but until I have the time to do that I need a fix/workaround.

Community
  • 1
  • 1
Terry
  • 1,889
  • 2
  • 12
  • 8
  • If you decide to move away from AcroPDFLib, the ImageMagick library is a free option that uses the Ghostscript engine for dealing with PDF. There's a .NET wrapper for ImageMagick to use with C#. Another option is the [LEADTOOLS professional PDF library](https://www.leadtools.com/sdk/pdf), which has a free evaluation edition. Note I'm an employee of LEADTOOLS vendor. – Amin Dodin Jan 19 '17 at 14:41

3 Answers3

1

After trying many of the solutions I have found during the last 8 hours of trying to solve this problem I have finally found this as a solution.

During the FormClosing event add the following

  • Use the loadFile routine to load a PDF that doesn't exist
  • Change the focus to some other object
  • Let other events fire
  • Sleep for 50

See my C# code below. If I remove any one of these lines the hang on form close reappears.

if (this.axPDF != null)
{
    axPDF.LoadFile("someFileThatDoesntExist.PDF");
    cmdNext.Focus();
    System.Windows.Forms.Application.DoEvents();
    System.Threading.Thread.Sleep(50);
    axPDF.Dispose();
}
chump
  • 11
  • 3
  • It isn't working for me in VB.NET. If I step through the code there is a delay of about 10 seconds at the Dispose. – Terry Feb 10 '17 at 13:30
0

I got the same problem.

Removing AxAcroPDF control from form's control collection when closing works for me.

A

0

There was no delay in my application this morning. I checked Programs and Features and found that Acrobat Reader has been updated to version 15.023.20070. It looks like Adobe has fixed the bug. I'm not seeing the delay any more.

If you've been having this problem, check to see if the update fixes it for you. In the last couple weeks I saw several workarounds that others said were working for them that did not work for me so it's possible my problem was not the same as others so this update may not fix everyone's problem. It appears to have fixed mine though.

Terry
  • 1,889
  • 2
  • 12
  • 8