LEADTOOLS Forms (Leadtools.Forms.DocumentReaders assembly)
LEAD Technologies, Inc

DocumentImageManager Class

Example 





Members 
Contains the image functionality associated with a DocumentReader.
Object Model
DocumentImageManager ClassDocumentReader Class
Syntax
public class DocumentImageManager 
'Declaration
 
Public Class DocumentImageManager 
'Usage
 
Dim instance As DocumentImageManager
public sealed class DocumentImageManager 
function Leadtools.Forms.DocumentReaders.DocumentImageManager()
public ref class DocumentImageManager 
Remarks

An instance of the DocumentImageManager isn't created directly, instead access the instance automatically created inside a DocumentReader using the DocumentReader.ImageManager property.

The DocumentImageManager contains the following functionality:

Example
 
Public Sub DocumentImageManagerExample()
   ' Get a document from the user
   Dim documentFileName As String

   Using openDlg As New OpenFileDialog()
      If openDlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
         Return
      End If

      documentFileName = openDlg.FileName
   End Using

   ' Load the document at 300 DPI for high quality rendering
   Dim loadOptions As New DocumentReaderLoadOptions()
   loadOptions.Resolution = 300
   Using reader As DocumentReader = DocumentReader.Create(documentFileName, loadOptions)
      ' Ask the user for the output TIFF file name
      Dim tiffFileName As String

      Using saveDlg As New SaveFileDialog()
         saveDlg.Filter = "TIFF files|*.tif;*.tiff|All Files|*.*"
         If saveDlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
            Return
         End If

         tiffFileName = saveDlg.FileName

         If File.Exists(tiffFileName) Then
            ' Because we will append pages, delete the file if it already exists
            File.Delete(tiffFileName)
         End If
      End Using

      ' Loop through all the pages and get a render of each
      For Each page As DocumentReaderPage In reader.Pages
         Using pageImage As RasterImage = reader.ImageManager.GetPageImage(page)
            ' Save it to the output file, we can use the RasterCodecs object
            ' of the reader
                  reader.RasterCodecsInstance.Save(pageImage, tiffFileName, RasterImageFormat.TifJpeg, _
                                                   24, 1, 1, -1, CodecsSavePageMode.Append)
         End Using
      Next
   End Using
End Sub
public void DocumentImageManagerExample()
{
   // Get a document from the user
   string documentFileName;

   using(OpenFileDialog openDlg = new OpenFileDialog())
   {
      if(openDlg.ShowDialog() != DialogResult.OK)
      {
         return;
      }

      documentFileName = openDlg.FileName;
   }

   // Load the document at 300 DPI for high quality rendering
   DocumentReaderLoadOptions loadOptions = new DocumentReaderLoadOptions();
   loadOptions.Resolution = 300;
   using(DocumentReader reader = DocumentReader.Create(documentFileName, loadOptions))
   {
      // Ask the user for the output TIFF file name
      string tiffFileName;

      using(SaveFileDialog saveDlg = new SaveFileDialog())
      {
         saveDlg.Filter = "TIFF files|*.tif;*.tiff|All Files|*.*";
         if(saveDlg.ShowDialog() != DialogResult.OK)
         {
            return;
         }

         tiffFileName = saveDlg.FileName;

         if(File.Exists(tiffFileName))
         {
            // Because we will append pages, delete the file if it already exists
            File.Delete(tiffFileName);
         }
      }

      // Loop through all the pages and get a render of each
      foreach(DocumentReaderPage page in reader.Pages)
      {
         using(RasterImage pageImage = reader.ImageManager.GetPageImage(page))
         {
            // Save it to the output file, we can use the RasterCodecs object
            // of the reader
            reader.RasterCodecsInstance.Save(pageImage, tiffFileName, RasterImageFormat.TifJpeg, 24, 1, 1, -1, CodecsSavePageMode.Append);
         }
      }
   }
}
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

See Also

Reference

DocumentImageManager Members
Leadtools.Forms.DocumentReaders Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Forms.DocumentWriters requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features