Search Results for

    Show / Hide Table of Contents

    Class AdvancedOcrResultBase

    Base class for advanced OCR results that support searchable PDF generation

    Inheritance
    System.Object
    AdvancedOcrResultBase
    OcrDocAdvancedResult
    OcrPhotoResult
    Implements
    IronSoftware.IOcrResult
    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 null, the PDF is not saved to disk.

    System.Boolean ApplyFilters

    Optional. If true, applies image filters to enhance the output PDF quality. Default is false.

    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.

    Related Documentation:

    📖How-To Guide: Learn more about creating searchable PDFs

    📚API Reference: See related searchable PDF methods

    Exceptions
    Type Condition
    IronOcrProductException

    Thrown when IronTesseract.Configuration.RenderSearchablePdf was not set to true before reading the document.

    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 true, applies image filters to enhance the output PDF quality. Default is false.

    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.

    Related Documentation:

    📖How-To Guide: Learn more about creating searchable PDFs

    📚API Reference: See related searchable PDF methods

    Exceptions
    Type Condition
    IronOcrProductException

    Thrown when IronTesseract.Configuration.RenderSearchablePdf was not set to true before reading the document.

    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 true, applies image filters to enhance the output PDF quality. Default is false.

    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.

    Related Documentation:

    📖How-To Guide: Learn more about creating searchable PDFs

    📚API Reference: See related searchable PDF methods

    Exceptions
    Type Condition
    IronOcrProductException

    Thrown when IronTesseract.Configuration.RenderSearchablePdf was not set to true before reading the document.

    Implements

    IronSoftware.IOcrResult
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronOCR to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronOCR free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.