Class OcrWithPostProcessingEngine

java.lang.Object
com.itextpdf.pdf2data.OcrWithPostProcessingEngine
All Implemented Interfaces:
com.itextpdf.pdfocr.IOcrEngine
Direct Known Subclasses:
Tesseract4BasedEngine

public class OcrWithPostProcessingEngine extends Object implements com.itextpdf.pdfocr.IOcrEngine
Engine which will apply post processors (if present) to results of base ocr engine.
  • Constructor Details

    • OcrWithPostProcessingEngine

      public OcrWithPostProcessingEngine (com.itextpdf.pdfocr.IOcrEngine baseOcrEngine, List<IOcrEnginePostProcessor> postProcessors, boolean isTaggingSupported)
      Creates new OcrWithPostProcessingEngine instance.
      Parameters:
      baseOcrEngine - base ocr engine which implements IOcrEngine
      postProcessors - List of IOcrEnginePostProcessor
      isTaggingSupported - if true results will be tagged, otherwise tag structure will be missing
  • Method Details

    • isTaggingSupported

      public boolean isTaggingSupported()
      Gets whether results will be tagged or not.
      Returns:
      true if results will be tagged, false otherwise;
    • doImageOcr

      public Map<Integer,List> doImageOcr (File input)
      Performs ocr with post-processing to your input file.
      Specified by:
      doImageOcr in interface com.itextpdf.pdfocr.IOcrEngine
      Parameters:
      input - input image File
      Returns:
      Map where key is Integer representing the number of the page and value is List of TextInfo elements where each TextInfo element contains a word or a line and its 4 coordinates (bbox)
    • doImageOcr

      public Map<Integer,List> doImageOcr (File input, com.itextpdf.pdfocr.OcrProcessContext ocrProcessContext)
      Performs ocr with post-processing to your input file.
      Specified by:
      doImageOcr in interface com.itextpdf.pdfocr.IOcrEngine
      Parameters:
      input - input image File
      ocrProcessContext - ocr processing context
      Returns:
      Map where key is Integer representing the number of the page and value is List of TextInfo elements where each TextInfo element contains a word or a line and its 4 coordinates (bbox)
    • createTxtFile

      public void createTxtFile (List<File> inputImages, File txtFile)
      Performs OCR using provided IOcrEngine for the given list of input images and saves output to a text file using provided path. Note that a human reading order is not guaranteed due to possible specifics of input images (multicolumn layout, tables etc.).
      Specified by:
      createTxtFile in interface com.itextpdf.pdfocr.IOcrEngine
      Parameters:
      inputImages - List of images to be OCRed
      txtFile - file to be created
    • createTxtFile

      public void createTxtFile (List<File> inputImages, File txtFile, com.itextpdf.pdfocr.OcrProcessContext ocrProcessContext)
      Performs OCR using provided IOcrEngine for the given list of input images and saves output to a text file using provided path. Note that a human reading order is not guaranteed due to possible specifics of input images (multicolumn layout, tables etc.).
      Specified by:
      createTxtFile in interface com.itextpdf.pdfocr.IOcrEngine
      Parameters:
      inputImages - List of images to be OCRed
      txtFile - file to be created
      ocrProcessContext - ocr processing context