Leadtools.Forms.DocumentReaders Namespace : DocumentImageManager Class |
public class DocumentImageManager
'Declaration Public Class DocumentImageManager
'Usage Dim instance As DocumentImageManager
public ref class DocumentImageManager
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:
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms Imports Leadtools.Forms.DocumentReaders Imports Leadtools.WinForms Imports Leadtools.Forms.Ocr Imports Leadtools.Drawing 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
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms; using Leadtools.Forms.DocumentReaders; using Leadtools.WinForms; using Leadtools.Forms.Ocr; using Leadtools.Drawing; 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); } } } }