PdfValidationOperation Read Function. Read and validate an existing document. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Read and validate an existing document.

 

   
Syntax  

[C#]
Doc Read(string path, XReadOptions options)
Doc Read(byte[] data, XReadOptions options)
Doc Read(Stream stream, XReadOptions options)

[Visual Basic]
Function Read(path As String, options As XReadOptions) As Doc
Function Read(data() As Byte, options As XReadOptions) As Doc
Function Read(stream As Stream, options As XReadOptions) As Doc

Throws Exceptions may throw Exception()

 

   

Params
 
Name Description
path The file path to PDF document.
data The source PDF data.
stream The source PDF stream.
options The settings for the read. (May be null.)

 

   

Notes
 

This method reads and validates the document according to the Conformance property. Any conformance error or warning is reported in the Errors property or the Warnings property after the method finishes.

If the Doc property is null, the document is read into a new Doc object, which is returned; otherwise, the document is read into the value of the Doc property, which is returned.

 

   

Example
 

Here we validate a document against PDF/A-1b format.

[C#]
string thePath = Server.MapPath("pdfa.pdf");
using(PdfValidationOperation theOperation = new PdfConformityOperation()) {
  theOperation.Conformance = PdfConformance.PdfA1b;
  Doc theDoc = theOperation.Read(thePath, null);
  theDoc.Dispose();

  if(theOperation.Errors.Count>0) {
    Console.WriteLine("Errors:");
    for(int i = 0; i<theOperation.Errors.Count; ++i)
      Console.WriteLine(theOperation.Errors[i]);
  }
  if(theOperation.Warnings.Count>0) {
    if(theOperation.Errors.Count>0)
      Console.WriteLine();
    Console.WriteLine("Warnings:");
    for(int i = 0; i<theOperation.Warnings.Count; ++i)
      Console.WriteLine(theOperation.Warnings[i]);
  }
}

[Visual Basic]
Dim thePath As String = Server.MapPath("pdfa.pdf")
Using theOperation As New PdfConformityOperation
  theOperation.Conformance = PdfConformance.PdfA1b
  Dim theDoc As Doc = theOperation.Read(thePath, Nothing)
  theDoc.Dispose()

  If theOperation.Errors.Count > 0 Then
    Console.WriteLine("Errors:")
    For i As Integer = 0 To theOperation.Errors.Count - 1
      Console.WriteLine(theOperation.Errors(i))
    Next
  End If
  If theOperation.Warnings.Count > 0 Then
    If theOperation.Errors.Count > 0 Then
      Console.WriteLine()
    End If
    Console.WriteLine("Warnings:")
    For i As Integer = 0 To theOperation.Warnings.Count - 1
      Console.WriteLine(theOperation.Warnings(i))
    Next
  End If
End Using