Class AdvancedOcrResultBase
Base class for advanced OCR results that support searchable PDF generation
Implements
Namespace: IronOcr
Assembly: IronOcr.dll
Syntax
public abstract class AdvancedOcrResultBase : Object, IOcrResult
Constructors
AdvancedOcrResultBase()
Declaration
protected AdvancedOcrResultBase()
Properties
Confidence
OCR statistical accuracy confidence as an average of every character.
1 = 100%, 0 = 0%.
Declaration
public abstract double Confidence { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Text
All OCR texts from OcrInput.
Declaration
public abstract string Text { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
SaveAsSearchablePdf(String, Boolean)
Exports the OCR result as a searchable PDF document and optionally saves it to a file.
A searchable PDF overlays invisible OCR text on the original image, allowing text selection and search while preserving the original appearance.
------------------------------------------------
Usage:
// Load OCR input
var input = new IronOcr.OcrInput();
input.LoadPdf("scanned.pdf");
// Instantiate OCR engine and enable searchable PDF rendering
var ocr = new IronOcr.IronTesseract();
ocr.Configuration.RenderSearchablePdf = true;
// Read the document
var result = ocr.ReadPhoto(input);
// Export and save as searchable PDF
byte[] pdfBytes = result.SaveAsSearchablePdf("output.pdf");
// The file is saved and bytes are also returned for further processing if needed
------------------------------------------------
Declaration
public byte[] SaveAsSearchablePdf(string Path = null, bool ApplyFilters = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Path | Optional. The file path where the PDF will be saved. If |
| System.Boolean | ApplyFilters | Optional. If |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the searchable PDF document. |
Remarks
Important Considerations:
⚠️Configuration Required: You must set IronTesseract.Configuration.RenderSearchablePdf = true before reading the document, otherwise this method will throw an exception.
💡Performance: The PDF bytes are cached after first generation, so subsequent calls return immediately without regenerating.
💡Filters: Setting ApplyFilters to true applies image enhancement filters to improve PDF quality.
💡File Path Optional: If Path is null, the PDF is not saved to disk but the bytes are still returned.
📖How-To Guide: Learn more about creating searchable PDFs
📚API Reference: See related searchable PDF methods
Exceptions
| Type | Condition |
|---|---|
| IronOcrProductException | Thrown when |
SaveAsSearchablePdfBytes(Boolean)
Exports the OCR result as a searchable PDF document and returns it as a byte array.
A searchable PDF overlays invisible OCR text on the original image, allowing text selection and search while preserving the original appearance.
------------------------------------------------
Usage:
// Load OCR input
var input = new IronOcr.OcrInput();
input.LoadPdf("scanned.pdf");
// Instantiate OCR engine and enable searchable PDF rendering
var ocr = new IronOcr.IronTesseract();
ocr.Configuration.RenderSearchablePdf = true;
// Read the document
var result = ocr.ReadPhoto(input);
// Export as searchable PDF bytes
byte[] pdfBytes = result.SaveAsSearchablePdfBytes();
System.IO.File.WriteAllBytes("output.pdf", pdfBytes);
------------------------------------------------
Declaration
public byte[] SaveAsSearchablePdfBytes(bool ApplyFilters = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | ApplyFilters | Optional. If |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the searchable PDF document. |
Remarks
Important Considerations:
⚠️Configuration Required: You must set IronTesseract.Configuration.RenderSearchablePdf = true before reading the document, otherwise this method will throw an exception.
💡Performance: The PDF bytes are cached after first generation, so subsequent calls return immediately without regenerating.
💡Filters: Setting ApplyFilters to true applies image enhancement filters to improve PDF quality.
📖How-To Guide: Learn more about creating searchable PDFs
📚API Reference: See related searchable PDF methods
Exceptions
| Type | Condition |
|---|---|
| IronOcrProductException | Thrown when |
SaveAsSearchablePdfStream(Boolean)
Exports the OCR result as a searchable PDF document and returns it as a Stream.
A searchable PDF overlays invisible OCR text on the original image, allowing text selection and search while preserving the original appearance.
------------------------------------------------
Usage:
// Load OCR input
var input = new IronOcr.OcrInput();
input.LoadPdf("scanned.pdf");
// Instantiate OCR engine and enable searchable PDF rendering
var ocr = new IronOcr.IronTesseract();
ocr.Configuration.RenderSearchablePdf = true;
// Read the document
var result = ocr.ReadPhoto(input);
// Export as searchable PDF stream
Stream pdfStream = result.SaveAsSearchablePdfStream();
// Use the stream (e.g., send via HTTP response, save to database, etc.)
------------------------------------------------
Declaration
public Stream SaveAsSearchablePdfStream(bool ApplyFilters = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | ApplyFilters | Optional. If |
Returns
| Type | Description |
|---|---|
| System.IO.Stream | A Stream containing the searchable PDF document. |
Remarks
Important Considerations:
⚠️Configuration Required: You must set IronTesseract.Configuration.RenderSearchablePdf = true before reading the document, otherwise this method will throw an exception.
💡Performance: This method returns a new MemoryStream containing the cached PDF bytes, so subsequent calls create new streams but don't regenerate the PDF.
💡Filters: Setting ApplyFilters to true applies image enhancement filters to improve PDF quality.
📖How-To Guide: Learn more about creating searchable PDFs
📚API Reference: See related searchable PDF methods
Exceptions
| Type | Condition |
|---|---|
| IronOcrProductException | Thrown when |