←Select platform

DocumentReaderLoadOptions Class

Summary

Provides options to use when reading a document.

Syntax

C#
VB
C++
public class DocumentReaderLoadOptions
Public Class DocumentReaderLoadOptions
public ref class DocumentReaderLoadOptions

Remarks

The DocumentReaderLoadOptions class is used as the type for the options optional parameter passed to DocumentReader.Create.

DocumentReaderLoadOptions contain the following:

Example

C#
VB
Public Sub DocumentReaderLoadOptionsExample() 
   Dim loadOptions As New DocumentReaderLoadOptions() 
   ' Load at 200 DPI 
   loadOptions.Resolution = 200 
   ' Use a new RasterCodecs 
   loadOptions.RasterCodecsInstance = Nothing 
   ' Set the callback to use if the document is encrypted 
   loadOptions.GetPasswordCallback = New DocumentReaderGetPasswordCallback(AddressOf MyGetPasswordCallback) 
   Dim documentFileName As String 
 
   Using dlg As New OpenFileDialog() 
      If dlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then 
         Return 
      End If 
 
      documentFileName = dlg.FileName 
   End Using 
 
   ' Load the document 
   Dim reader As DocumentReader = DocumentReader.Create(documentFileName, loadOptions) 
 
   ' If the value of reader is Nothing, then the document was encrypted and the user hit cancel 
   ' for the dialog 
   If IsNothing(reader) Then 
      MessageBox.Show("Canceled") 
   Else 
      ' Document is loaded, show its properties 
      Dim sb As New StringBuilder() 
      sb.AppendFormat("Reader used: {0}\n", reader.ReaderType) 
      sb.AppendFormat("MIME type: {0}\n", reader.MimeType) 
      sb.AppendFormat("Document has {0} pages", reader.Pages.Count) 
      MessageBox.Show(sb.ToString()) 
 
      reader.Dispose() 
   End If 
End Sub 
 
Private Function MyGetPasswordCallback(ByVal fileName As String) As String 
   MessageBox.Show(String.Format("{0}\nIs encrypted. Enter a password", fileName)) 
 
   ' Will simulate a password, in your application you could show a dialog box 
   ' here asking the user for a pssword 
   Return "lead" 
 
   ' Or you can return Nothing, to cancel reading the document without an exception 
   ' being thrown. DocumentReader.Create will return Nothing as well 
End Function 
public void DocumentReaderLoadOptionsExample() 
{ 
   DocumentReaderLoadOptions loadOptions = new DocumentReaderLoadOptions(); 
   // Load at 200 DPI 
   loadOptions.Resolution = 200; 
   // Use a new RasterCodecs 
   loadOptions.RasterCodecsInstance = null; 
   // Set the callback to use if the document is encrypted 
   loadOptions.GetPasswordCallback = new DocumentReaderGetPasswordCallback(MyGetPasswordCallback); 
   string documentFileName; 
 
   using(OpenFileDialog dlg = new OpenFileDialog()) 
   { 
      if(dlg.ShowDialog() != DialogResult.OK) 
      { 
         return; 
      } 
 
      documentFileName = dlg.FileName; 
   } 
 
   // Load the document 
   DocumentReader reader = DocumentReader.Create(documentFileName, loadOptions); 
 
   // If the value of reader is null, then the document was encrypted and the user hit cancel 
   // for the dialog 
   if(reader == null) 
   { 
      MessageBox.Show("Canceled"); 
   } 
   else 
   { 
      // Document is loaded, show its properties 
      StringBuilder sb = new StringBuilder(); 
      sb.AppendFormat("Reader used: {0}\n", reader.ReaderType); 
      sb.AppendFormat("MIME type: {0}\n", reader.MimeType); 
      sb.AppendFormat("Document has {0} pages", reader.Pages.Count); 
      MessageBox.Show(sb.ToString()); 
 
      reader.Dispose(); 
   } 
} 
 
private string MyGetPasswordCallback(string fileName) 
{ 
   MessageBox.Show(string.Format("{0}\nIs encrypted. Enter a password", fileName)); 
 
   // Will simulate a password, in your application you could show a dialog box 
   // here asking the user for a pssword 
   return "lead"; 
 
   // Or you can return null, to cancel reading the document without an exception 
   // being thrown. DocumentReader.Create will return null as well 
} 

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Forms.DocumentReaders Assembly
Click or drag to resize