Class OCRJob

  • public class OCRJob
    extends PDFServicesJob
    A job that convert a PDF file into a searchable PDF file. Allows specifying locale(OCRSupportedLocale) and OCR Type (OCRSupportedType) for performing OCR (Optical Character Recognition)

    Sample Usage:

                 InputStream inputStream = new FileInputStream(new File("SOURCE_PATH"));
                 Credentials credentials = new ServicePrincipalCredentials(
                 PDFServices pdfServices = new PDFServices(credentials);
                 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
                  OCRJob ocrJob = new OCRJob(asset);
                 String location = pdfServices.submit(ocrJOB);
                 PDFServicesResponse<OCRResult> pdfServicesResponse = pdfServices.getJobResult(location, OCRResult.class);
                 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
                 StreamAsset StreamAsset = pdfServices.getContent(linearizeAssetResult);
    • Constructor Detail

      • OCRJob

        public OCRJob​(Asset asset)
        Constructs a new OCRJob instance.
        asset - Asset object containing the input file; can not be null.
    • Method Detail

      • setParams

        public OCRJob setParams​(OCRParams ocrParams)
        Set params for the job.
        ocrParams - OCRParams object containing the OCR parameters; can not be null.
        this OCRJob instance
      • setOutput

        public OCRJob setOutput​(Asset asset)
        Sets the output asset for the job. @note External assets can be set as output only when input is external asset as well
        asset - Asset object representing the output asset; can not be null.
        OCRJob instance