VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
In This Topic
PDF: Load PDF document
In This Topic
The SDK allows to load a PDF document compliant with PDF specification version 1.0 - 2.0. Each of loaded PDFs can be secured with ARC4 or AES algorithms. The SDK allows also to load damaged PDF documents.

Here is C#/VB.NET code that demonstrates how to load a non-secured PDF document from file:
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


Here is C#/VB.NET code that demonstrates how to load a PDF document, for case, when it is not known in advance that the PDF document is secured:
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