Avoid the news since Acrobat messages when it is opened to broken PDF document

I use Adobe SDK to check and fix a bunch of PDF files

Dim avDoc As AcroAVDoc = Nothing
    Dim pdDoc As CAcroPDDoc = Nothing
    Try
        avDoc = New AcroAVDoc()
        If (avDoc.Open(sourceFile.FullName, String.Empty)) Then
            pdDoc = avDoc.GetPDDoc()
            RemoveIfExists(destinationFile)
            CreateIfNotExits(New DirectoryInfo(destinationFile.DirectoryName))
            pdDoc.Save(3, destinationFile.FullName)
            pdDoc.Close()
            avDoc.Close(1)
            Return True
        End If
        Return False
    Catch generatedExceptionName As Exception
        Me.logger.Error(String.Format("Error while converting {0} to {1}. The error message: {2}", sourceFile.FullName, destinationFile.FullName, generatedExceptionName.Message))
        Me.logger.Fatal(generatedExceptionName.StackTrace)
        Return False
    Finally
        If (avDoc IsNot Nothing) Then
            avDoc.Close(1)
        End If
        If (pdDoc IsNot Nothing) Then
            pdDoc.Close()
        End If
    End Try

But when I try to open the PDF file that cannot be opened for any reason, the information message

Capture.PNG

How to avoid this?

Open the document as a PDDoc first, then convert to an AVDoc. Use an error

Manager to trap the error that is thrown by the Open when call the file

cannot be opened.

pdDoc.Open("c:\test\dummy.pdf")

pdDoc.OpenAVDoc (' ')

Karl Heinz Kremer

PDF acrobatics without a net

PDF, training software development and much more...

[email protected]

http://www.khkonsulting.com

Tags: Acrobat

Similar Questions

Maybe you are looking for