Class OCREngine

java.lang.Object
com.datalogics.PDFL.OCREngine

public class OCREngine extends Object
Represents an OCR Engine and its configuration. Create an OCREngine object once, and reuse it to convert multiple images to Form objects to avoid repeating the sometimes expensive initialization of the engine. The configuration of the engine can't be changed after it's created; if you need to do that, create another OCREngine object.
  • Constructor Details

    • OCREngine

      public OCREngine()
      Create an OCR engine.
    • OCREngine

      public OCREngine(OCRParams ocrParams)
      Create an OCR engine with a specified configuration.
      Parameters:
      ocrParams - the configuration to use
  • Method Details

    • delete

      public void delete()
    • placeTextUnder

      public Form placeTextUnder(Image image)
      Recognize text in the image, returning a form element with the image and the text underneath. Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

      This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

      Parameters:
      image - The image in which to recognize text.
      Returns:
      a Form element containing the image with text underneath.
    • placeTextUnder

      public Form placeTextUnder(Image image, Document inDocument)
      Recognize text in the image, returning a form element with the image and the text underneath. Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

      The form will be created in the specified document, sharing fonts with the results of recognizing text in other images.

      This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

      Parameters:
      image - The image in which to recognize text.
      inDocument - The destination document for the created form.
      Returns:
      a Form element containing the image with text underneath.
    • isLanguageAvailable

      public boolean isLanguageAvailable(Language language)
      Query if a language for OCR is available for use.
      Parameters:
      language - the language to check
      Returns:
      true if the language is available, false otherwise
    • getAvailableLanguages

      public List<Language> getAvailableLanguages()
      Get a list of languages this OCREngine can use.
      Returns:
      the list of languages supported, or null if that list can't be determined.