public class OCROperation extends Object implements Operation
OCRSupportedLocale
) and OCR Type
(OCRSupportedType
) for performing OCR (Optical Character Recognition)
Sample Usage:
OCROperation ocrOperation = OCROperation.createNew();
ocrOperation.setInput(FileRef.createFromLocalFile("~/Documents/ocrOperationInput.pdf",
OCROperation.SupportedSourceFormat.PDF.getMediaType()));
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdfservices-api-credentials.json").build();
FileRef result = ocrOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/ocrOperationOutput.pdf");
Modifier and Type | Class and Description |
---|---|
static class |
OCROperation.SupportedSourceFormat
Supported source file formats for
OCROperation . |
Modifier and Type | Method and Description |
---|---|
static OCROperation |
createNew()
Constructs a
OCROperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting PDF file.
|
void |
setInput(FileRef sourceFileRef)
Sets an input file.
|
void |
setOptions(OCROptions ocrOptions)
Sets the options for this operation.
|
public static OCROperation createNew()
OCROperation
instance.OCROperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input filepublic void setOptions(OCROptions ocrOptions)
OCROptions
for how to specify the
options for the different locales and ocr types.ocrOptions
- optional parameters; use null for default valuespublic FileRef execute(ExecutionContext context) throws ServiceApiException, IOException, ServiceUsageException
The resulting file may be stored in the system temporary directory (per java.io.tmpdir System property).
See FileRef
for how temporary resources are cleaned up.
execute
in interface Operation
context
- the context in which to execute the operationServiceApiException
- if an API call results in an error responseIOException
- if there is an error in reading either the input source or the resulting PDF fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2022 Adobe. All rights reserved.