public RasterImage PageImage { get; set; } Public Property PageImage As RasterImage @property (nonatomic, strong, nullable) LTRasterImage *pageImage public RasterImage getPageImage()public void setPageImage(RasterImage value)
public:property RasterImage^ PageImage {RasterImage^ get();void set ( RasterImage^ );}
An RasterImage instance that specifies the raster image being used in the current operation if any.
This member is valid only when the current operation is:
| Operation | Description |
|---|---|
| OcrAutoRecognizeManagerJobOperation.LoadPage |
When the value of PostOperation is false, then PageImage holds the raster image object to be used to create the IOcrPage. By default this will be null and the engine will load the image from the input document. You can override this behavior by setting your own RasterImage in this property. The engine will use the supplied image to create the page. |
| OcrAutoRecognizeManagerJobOperation.SavePage |
PageImage holds the raster image to be used with the final document if the page contains graphics zone (to obtain the graphics area) or if the format supports "image over text" such as PDF with Image/Text. By default this is either the original image of the page (same instance obtained through IOcrPage.GetRasterImage with OcrPageType.Original or the overlay image if the user set a value using IOcrPage.SetOverlayImage. You can set your own image to be used for this purpose by setting the value in PageImage during this operation when PostOperation is false. Note that the engine will not dispose this image reference, therefore, it is recommended that the user will call Dispose on PageImage in the next event occurrence (when PostOperation is true). |
using Leadtools;using Leadtools.Codecs;using Leadtools.Ocr;using Leadtools.Document.Writer;using Leadtools.Forms.Common;using Leadtools.WinForms;private static void PageExampleExample(){var imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");var outFileName = Path.Combine(LEAD_VARS.ImagesDir, "result.pdf");using (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)){ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);// Use PDF with image/text optionvar pdfOptions = ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;pdfOptions.ImageOverText = true;ocrEngine.DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfOptions);// Create an OCR AutoRecognize jobvar jobData = new OcrAutoRecognizeJobData{ImageFileName = imageFileName,FirstPageNumber = 1,LastPageNumber = -1,DocumentFileName = outFileName,Format = DocumentFormat.Pdf};var autoRecognizeManager = ocrEngine.AutoRecognizeManager;var job = autoRecognizeManager.CreateJob(jobData);EventHandler<OcrAutoRecognizeJobOperationEventArgs> jobOperation = (sender, e) =>{if (e.Operation == OcrAutoRecognizeManagerJobOperation.SavePage){if (!e.PostOperation){// We will set a new image that is all white, same size and resolution as the// pagevar overlayImage = RasterImage.Create(e.Page.Width,e.Page.Height,24,e.Page.DpiX,RasterColor.FromKnownColor(RasterKnownColor.White));e.PageImage = overlayImage;}else{// Dispose the image we createde.PageImage.Dispose();e.PageImage = null;}}};autoRecognizeManager.JobOperation += jobOperation;OcrAutoRecognizeManagerJobStatus status;try{status = autoRecognizeManager.RunJob(job);}finally{autoRecognizeManager.JobOperation -= jobOperation;}Console.WriteLine(status);// The result PDF file will have an overlay image that is all white, with recognition text underneeth}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS21\Bin\Common\OcrLEADRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.OcrImports Leadtools.Document.WriterImports Leadtools.Forms.CommonImports Leadtools.WinFormsPrivate Shared Sub PageExampleExample()Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif")Dim outFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "result.pdf")Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir)' Use PDF with image/text optionDim pdfOptions As PdfDocumentOptions = DirectCast(ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf), PdfDocumentOptions)pdfOptions.ImageOverText = TrueocrEngine.DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfOptions)' Create an OCR AutoRecognize jobDim jobData As New OcrAutoRecognizeJobDatajobData.ImageFileName = imageFileNamejobData.FirstPageNumber = 1jobData.LastPageNumber = -1jobData.DocumentFileName = outFileNamejobData.Format = DocumentFormat.PdfDim autoRecognizeManager As IOcrAutoRecognizeManager = ocrEngine.AutoRecognizeManagerDim job As IOcrAutoRecognizeJob = autoRecognizeManager.CreateJob(jobData)Dim jobOperation As EventHandler(Of OcrAutoRecognizeJobOperationEventArgs) =Sub(sender As Object, e As OcrAutoRecognizeJobOperationEventArgs)If e.Operation = OcrAutoRecognizeManagerJobOperation.SavePage ThenIf Not e.PostOperation Then' We will set a new image that is all white, same size and resolution as the' pageDim overlayImage As RasterImage = RasterImage.Create(e.Page.Width,e.Page.Height,24,e.Page.DpiX,RasterColor.FromKnownColor(RasterKnownColor.White))e.PageImage = overlayImageElse' Dispose the image we createde.PageImage.Dispose()e.PageImage = NothingEnd IfEnd IfEnd SubAddHandler autoRecognizeManager.JobOperation, jobOperationDim status As OcrAutoRecognizeManagerJobStatusTrystatus = autoRecognizeManager.RunJob(job)FinallyRemoveHandler autoRecognizeManager.JobOperation, jobOperationEnd TryConsole.WriteLine(status)' The result PDF file will have an overlay image that is all white, with recognition text underneathEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS21\Bin\Common\OcrLEADRuntime"End Class
OcrAutoRecognizeJobOperationEventArgs Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
