Cómo usar seguimiento de OcrProgress en C#

How to Use Progress Tracking

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronOCR provides an event for subscribing to track the progress of the OCR (Optical Character Recognition) reading operation. These properties offer valuable information about the progress, duration, and completion status of the OCR job, enabling applications to effectively monitor and report on the OCR process.

Quickstart: Subscribe to OcrProgress and Read PDF

This example shows how effortlessly you can monitor OCR progress with IronOCR: subscribe to its built-in OcrProgress event and get instant feedback (percentage, pages done, total pages) while reading a PDF. It’s a few lines to get started.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. Copy and run this code snippet.

    var ocr = new IronOcr.IronTesseract();
    ocr.OcrProgress += (s, e) => Console.WriteLine(e.ProgressPercent + "% (" + e.PagesComplete + "/" + e.TotalPages + ")");
    var result = ocr.Read(new IronOcr.OcrInput().LoadPdf("file.pdf"));
  3. Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer


Progress Tracking Example

The OcrProgress event can be subscribed to receive progress updates on the reading process. The event will pass an instance containing information about the progress of the OCR job, such as the start time, total pages, progress as a percentage, duration, and end time. Let's use the following document as our sample: "Experiences in Biodiversity Research: A Field Course" by Thea B. Gessler, Iowa State University.

:path=/static-assets/ocr/content-code-examples/how-to/progress-tracking-progress-tracking.cs
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

// Subscribe to OcrProgress event
ocrTesseract.OcrProgress += (_, ocrProgressEventsArgs) =>
{
    Console.WriteLine("Start time: " + ocrProgressEventsArgs.StartTimeUTC.ToString());
    Console.WriteLine("Total pages number: " + ocrProgressEventsArgs.TotalPages);
    Console.WriteLine("Progress(%) | Duration");
    Console.WriteLine("    " + ocrProgressEventsArgs.ProgressPercent + "%     | " + ocrProgressEventsArgs.Duration.TotalSeconds + "s");
    Console.WriteLine("End time: " + ocrProgressEventsArgs.EndTimeUTC.ToString());
    Console.WriteLine("----------------------------------------------");
};

using var input = new OcrInput();
input.LoadPdf("Experiences-in-Biodiversity-Research-A-Field-Course.pdf");

// Progress events will fire during the read operation
var result = ocrTesseract.Read(input);
Imports IronOcr
Imports System

Private ocrTesseract = New IronTesseract()

' Subscribe to OcrProgress event
Private ocrTesseract.OcrProgress += Sub(underscore, ocrProgressEventsArgs)
	Console.WriteLine("Start time: " & ocrProgressEventsArgs.StartTimeUTC.ToString())
	Console.WriteLine("Total pages number: " & ocrProgressEventsArgs.TotalPages)
	Console.WriteLine("Progress(%) | Duration")
	Console.WriteLine("    " & ocrProgressEventsArgs.ProgressPercent & "%     | " & ocrProgressEventsArgs.Duration.TotalSeconds & "s")
	Console.WriteLine("End time: " & ocrProgressEventsArgs.EndTimeUTC.ToString())
	Console.WriteLine("----------------------------------------------")
End Sub

Private input = New OcrInput()
input.LoadPdf("Experiences-in-Biodiversity-Research-A-Field-Course.pdf")

' Progress events will fire during the read operation
Dim result = ocrTesseract.Read(input)
$vbLabelText   $csharpLabel
Progress update

Information from the Event

  • ProgressPercent: Represents the progress of the OCR job as a percentage of pages completed. It ranges from 0 to 100.
  • TotalPages: Indicates the total number of pages being processed by the OCR engine.
  • PagesComplete: Specifies the number of pages where OCR reading has been fully completed. This count may increase gradually as pages are processed.
  • Duration: Represents the total duration of the OCR job, indicating the time taken for the entire process to complete. It's measured in TimeSpan format. This time is updated every time the event is triggered.
  • StartTimeUTC: Denotes the date and time when the OCR job started, represented in Coordinated Universal Time (UTC) format.
  • EndTimeUTC: Represents the date and time when the OCR job was 100% completed in UTC format. This property is null while OCR is still in progress and gets populated once the OCR process is finished.

Preguntas Frecuentes

¿Cómo puedo rastrear el progreso de una tarea OCR en C#?

Puedes rastrear el progreso de una tarea OCR en C# suscribiéndote al evento OcrProgress en IronOCR. Este evento proporciona actualizaciones sobre el porcentaje de finalización, duración y número de páginas procesadas.

¿Cuál es el papel del evento OcrProgress en las operaciones de OCR?

El evento OcrProgress en IronOCR permite a los desarrolladores recibir actualizaciones en tiempo real sobre el estado de la tarea OCR, incluyendo el porcentaje de progreso, duración total, tiempos de inicio y fin, y el total de páginas procesadas.

¿Qué información proporciona la propiedad ProgressPercent?

La propiedad ProgressPercent en IronOCR indica el progreso de la tarea OCR como un porcentaje, proporcionando una visión clara de cuánto de la tarea está completada, en un rango de 0 a 100.

¿Cómo obtengo la duración total de un proceso OCR?

Puedes obtener la duración total de un proceso OCR accediendo a la propiedad Duration en IronOCR, la cual se actualiza cada vez que se activa el evento OcrProgress, reflejando el tiempo total del proceso.

¿Puedo determinar cuándo una tarea OCR empieza y termina?

Sí, IronOCR proporciona las propiedades StartTimeUTC y EndTimeUTC, que denotan las horas de inicio y finalización de la tarea OCR en formato UTC, respectivamente.

¿Cómo manejo múltiples páginas durante el procesamiento OCR?

En IronOCR, puedes manejar múltiples páginas usando las propiedades TotalPages y PagesComplete para rastrear el número total de páginas procesadas y las páginas que han sido completamente procesadas.

¿Cuál es un ejemplo práctico de uso del seguimiento de progreso en OCR?

Un ejemplo práctico implica suscribirse al evento OcrProgress mientras se procesa un documento de muestra titulado 'Experiences in Biodiversity Research: A Field Course.' Esto demuestra cómo rastrear el progreso, duración y el estado de finalización en IronOCR.

Chaknith Bin
Ingeniero de Software
Chaknith trabaja en IronXL e IronBarcode. Tiene un profundo conocimiento en C# y .NET, ayudando a mejorar el software y apoyar a los clientes. Sus conocimientos derivados de las interacciones con los usuarios contribuyen a mejores productos, documentación y experiencia en general.
¿Listo para empezar?
Nuget Descargas 5,044,537 | Versión: 2025.11 recién lanzado