Gets or sets the image used with the current operation.
public Leadtools.RasterImage PageImage {get; set;} Public Property PageImage As Leadtools.RasterImage @property (nonatomic, strong, nullable) LTRasterImage *pageImage public RasterImage getPageImage()public void setPageImage(RasterImage value)
public:property Leadtools.RasterImage^ PageImage {Leadtools.RasterImage^ get();void set ( Leadtools.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.Forms.Ocr;using Leadtools.Forms.DocumentWriters;using Leadtools.Forms;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.Advantage, false)){ocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir);// 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:\Users\Public\Documents\LEADTOOLS Images";public const string OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Forms.OcrImports Leadtools.Forms.DocumentWritersImports Leadtools.FormsImports 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.Advantage, False)ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)' 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 underneethEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"Public Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"End Class
OcrAutoRecognizeJobOperationEventArgs Class
|
Products |
Support |
Feedback: PageImage Property - Leadtools.Forms.Ocr |
Introduction |
Help Version 19.0.2017.6.6
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.