Click or drag to resize

ExaminerResultsFromStream Method

Overload List
  NameDescription
Public methodStatic memberCode exampleFromStream(Stream)
Attempts to build an ExaminerResults object from the stream provided. To the greatest extent possible, FromStream attempts to get some information from the file. If the file is a PDF and it is encrypted, FromStream will throw an IncorrectPasswordException.
Note that many of the properties in the file cascade. For example, if IsPdf returns false, no other property will be valid. If IsEncrypted is true, no other properties except IsPdf, IsPdfA, and IsIncorrectVersionForXrefStream will be valid.
The properties within ExaminerResults are meant to reflect a very lightweight examination of the file and are in no way are exhaustive. PDF is a very complicated file format and there are a number of exceptions in the specification that are counter to the goal of having a light-weight interface to the information within the file. For example, because a PDF file presents information that indicates that it meets the archival variant, PDF/A, this doesn't guarantee that the document meets all requirements. ExaminerResults reflects what is advertised by the file and not necessarily the entire depth of content.
The stream position can not be counted on to be at a consistent location upon return.
If the document is encrypted, FromStream will throw an IncorrectPasswordException.
Examples
The following example examines PDF document. If PDF document is encrypted, a password will be requested from the user.
ExaminePdfExample
ExaminerResults res = null;

using (FileStream stm = File.OpenRead(path))
{
    try
    {
        res = ExaminerResults.FromStream(stm);
    }
    catch (IncorrectPasswordException)
    {
        while (true)
        {
            using (var userSecure = GetPasswordFromUser())
                try
                {
                    res = ExaminerResults.FromStream(stm, userSecure, null);
                    break;
                }
                catch (IncorrectPasswordException)
                {
                    OnIncorrectUserPassword();
                }
        }
    }

}
Public methodStatic memberCode exampleFromStream(Stream, SecureString, SecureString)
Attempts to build an ExaminerResults object from the stream provided. To the greatest extent possible, FromStream attempts to get some information from the file. If the file is a PDF and it is encrypted, FromStream will throw an IncorrectPasswordException.
Note that many of the properties in the file cascade. For example, if IsPdf returns false, no other property will be valid. If IsEncrypted is true, no other properties except IsPdf, IsPdfA, and IsIncorrectVersionForXrefStream will be valid.
The properties within ExaminerResults are meant to reflect a very lightweight examination of the file and are in no way are exhaustive. PDF is a very complicated file format and there are a number of exceptions in the specification that are counter to the goal of having a light-weight interface to the information within the file. For example, because a PDF file presents information that indicates that it meets the archival variant, PDF/A, this doesn't guarantee that the document meets all requirements. ExaminerResults reflects what is advertised by the file and not necessarily the entire depth of content.
The stream position can not be counted on to be at a consistent location upon return.
The supplied passwords may either or both be null indicating no password. If passwords are supplied and the document is not encrypted, the passwords will be ignored. If the document is encrypted and the password(s) are incorrect or null FromStream will throw an IncorrectPasswordException.
Examples
The following example examines PDF document. If PDF document is encrypted, a password will be requested from the user.
ExaminePdfExample
ExaminerResults res = null;

using (FileStream stm = File.OpenRead(path))
{
    try
    {
        res = ExaminerResults.FromStream(stm);
    }
    catch (IncorrectPasswordException)
    {
        while (true)
        {
            using (var userSecure = GetPasswordFromUser())
                try
                {
                    res = ExaminerResults.FromStream(stm, userSecure, null);
                    break;
                }
                catch (IncorrectPasswordException)
                {
                    OnIncorrectUserPassword();
                }
        }
    }

}
Public methodStatic memberCode exampleFromStream(Stream, String, String) Obsolete.
Attempts to build an ExaminerResults object from the stream provided. To the greatest extent possible, FromStream attempts to get some information from the file. If the file is a PDF and it is encrypted, FromStream will throw an IncorrectPasswordException.
Note that many of the properties in the file cascade. For example, if IsPdf returns false, no other property will be valid. If IsEncrypted is true, no other properties except IsPdf, IsPdfA, and IsIncorrectVersionForXrefStream will be valid.
The properties within ExaminerResults are meant to reflect a very lightweight examination of the file and are in no way are exhaustive. PDF is a very complicated file format and there are a number of exceptions in the specification that are counter to the goal of having a light-weight interface to the information within the file. For example, because a PDF file presents information that indicates that it meets the archival variant, PDF/A, this doesn't guarantee that the document meets all requirements. ExaminerResults reflects what is advertised by the file and not necessarily the entire depth of content.
The stream position can not be counted on to be at a consistent location upon return.
The supplied passwords may either or both be null indicating no password. If passwords are supplied and the document is not encrypted, the passwords will be ignored. If the document is encrypted and the password(s) are incorrect or null FromStream will throw an IncorrectPasswordException.
Examples
The following example examines PDF document. If PDF document is encrypted, a password will be requested from the user.
ExaminePdfExample
ExaminerResults res = null;

using (FileStream stm = File.OpenRead(path))
{
    try
    {
        res = ExaminerResults.FromStream(stm);
    }
    catch (IncorrectPasswordException)
    {
        while (true)
        {
            using (var userSecure = GetPasswordFromUser())
                try
                {
                    res = ExaminerResults.FromStream(stm, userSecure, null);
                    break;
                }
                catch (IncorrectPasswordException)
                {
                    OnIncorrectUserPassword();
                }
        }
    }

}
Top
See Also