VintaSoft Imaging .NET SDK 15.2: Документация для .NET разработчика
В этом разделе
PDF: Загрузка PDF документа
В этом разделе
VintaSoft Imaging .NET SDK позволяет загружать PDF документы, соответствующие стандарту PDF версии 1.0 - 2.0. Каждый из загружаемых PDF документов может быть защищен алгоритмами ARC4 или AES. SDK также позволяет загружать поврежденные PDF документы.

Вот C#/VB.NET код, который демонстрирует, как загрузить не защищенный PDF документ из файла:
public static Vintasoft.Imaging.Pdf.PdfDocument LoadPdfDocumentFromFile(string filename)
{
    return new Vintasoft.Imaging.Pdf.PdfDocument(filename);
}
Public Shared Function LoadPdfDocumentFromFile(filename As String) As Vintasoft.Imaging.Pdf.PdfDocument
    Return New Vintasoft.Imaging.Pdf.PdfDocument(filename)
End Function


Вот C#/VB.NET код, который демонстрирует, как загрузить PDF документ в случае, когда заранее неизвестно, защищен ли документ:
namespace UserGuide.Programming.Pdf.Encryption
{
    class OpenPdfDocument
    {
        public static Vintasoft.Imaging.Pdf.PdfDocument Open(string filename)
        {
            Vintasoft.Imaging.Pdf.PdfDocument document = 
                new Vintasoft.Imaging.Pdf.PdfDocument(filename);
            if (document.IsEncrypted)
            {
                while (true)
                {
                    System.Console.Write("Enter password: ");
                    // get password string
                    string password = System.Console.ReadLine();
                    // performs authentication
                    Vintasoft.Imaging.Pdf.Security.AuthorizationResult authorization = 
                        document.Authenticate(password);
                    // check authorization result
                    if (authorization == Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword)
                    {
                        System.Console.WriteLine("The password is incorrect.");
                    }
                    else
                    {
                        System.Console.WriteLine(authorization.ToString());
                        break;
                    }
                }
            }
            return document;
        }
    }
}
Namespace UserGuide.Programming.Pdf.Encryption
    Class OpenPdfDocument
        Public Shared Function Open(filename As String) As Vintasoft.Imaging.Pdf.PdfDocument
            Dim document As New Vintasoft.Imaging.Pdf.PdfDocument(filename)
            If document.IsEncrypted Then
                While True
                    System.Console.Write("Enter password: ")
                    ' get password string
                    Dim password As String = System.Console.ReadLine()
                    ' performs authentication
                    Dim authorization As Vintasoft.Imaging.Pdf.Security.AuthorizationResult = document.Authenticate(password)
                    ' check authorization result
                    If authorization = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword Then
                        System.Console.WriteLine("The password is incorrect.")
                    Else
                        System.Console.WriteLine(authorization.ToString())
                        Exit While
                    End If
                End While
            End If
            Return document
        End Function
    End Class
End Namespace