You can't. If the document is corrupt beyond repair PDFDoc will throw an exception. To handle corrupt documents simply catch the exception and deal with the file as if it is corrupt (unless the problem is bad path .. to differentiate you could open the doc via Filter first, or test the error message, ... or verity the path is correct).
Not PDFNet can open many badly damaged and corrupt PDF files. If you would like to find out if the file was auto-repaired (and is therefore damaged) check doc.IsModified() immediately after opening the document.
and it works as expected. The issue is that you are not catching the exception. So just surround your code with
try { ... }
catch (PDFNetException e)
{
Console.WriteLine(e.Message);
}
Or maybe the issue is that you are using ancient version of PDFNet (v.4.0)... The current version is 6.1.2
Not sure what do you mean with this? If you are thinking about time, PDFDoc() will be extremely fast even on huge documents. If you need to guarantee that the line will execute in a specific time span you can open PDFDoc in a separate thread. Btw. if you are using PDFNet for WinRt there are extra utility methods to create document asynchronously (i.e. PDFDoc.CreateAsync...)