com.adobe.pdfservices.operation.pdfjobs.params.ocr.OCRParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdfservices-sdk Show documentation
Show all versions of pdfservices-sdk Show documentation
Adobe PDF Services SDK allows you to access RESTful APIs to create, convert, and manipulate PDFs within your applications.
Older versions can be found under groupId: com.adobe.documentservices, artifactId: pdftools-sdk
/*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in
* accordance with the terms of the Adobe license agreement accompanying
* it. If you have received this file from a source other than Adobe,
* then your use, modification, or distribution of it requires the prior
* written permission of Adobe.
*/
package com.adobe.pdfservices.operation.pdfjobs.params.ocr;
import com.adobe.pdfservices.operation.internal.constants.CustomErrorMessages;
import com.adobe.pdfservices.operation.internal.util.ObjectUtil;
import com.adobe.pdfservices.operation.pdfjobs.jobs.OCRJob;
import com.adobe.pdfservices.operation.pdfjobs.params.PDFServicesJobParams;
/**
* Parameters for converting PDF to a searchable PDF using {@link OCRJob}.
*/
public class OCRParams implements PDFServicesJobParams {
private OCRSupportedLocale ocrLocale;
private OCRSupportedType ocrType;
private OCRParams(Builder builder) {
this.ocrLocale = builder.ocrLocale;
this.ocrType = builder.ocrType;
}
/**
* Returns the {@link OCRSupportedLocale} to be used for OCR.
*
* @return an {@link OCRSupportedLocale} instance
*/
public OCRSupportedLocale getOCRLocale() {
return ocrLocale;
}
/**
* Returns the {@link OCRSupportedType} to be used for OCR.
*
* @return an {@link OCRSupportedType} instance
*/
public OCRSupportedType getOCRType() {
return ocrType;
}
/**
* Creates a new {@link Builder}.
*
* @return an {@link Builder} instance
*/
public static Builder ocrParamsBuilder() {
return new Builder();
}
/**
* Builds an {@link OCRParams} instance.
*/
public static class Builder {
private OCRSupportedLocale ocrLocale;
private OCRSupportedType ocrType;
/**
* Constructs a {@code OCRParams.Builder} instance.
*/
public Builder() {
ocrLocale = OCRSupportedLocale.EN_US;
ocrType = OCRSupportedType.SEARCHABLE_IMAGE;
}
/**
* Sets input language to be used for OCR, specified by {@link OCRSupportedLocale}.
*
* @param ocrSupportedLocale see {@link OCRSupportedLocale}; can not be null. Default value is
* {@link OCRSupportedLocale#EN_US}
* @return this Builder instance to add any additional parameters
*/
public Builder withOCRLocale(OCRSupportedLocale ocrSupportedLocale) {
ObjectUtil.requireNonNull(ocrSupportedLocale, String.format(CustomErrorMessages.GENERIC_CAN_NOT_BE_NULL,
"OCR Locale"));
this.ocrLocale = ocrSupportedLocale;
return this;
}
/**
* Sets OCR type, specified by {@link OCRSupportedType}
*
* @param ocrSupportedType see {@link OCRSupportedType}; can not be null. Default value is
* {@link OCRSupportedType#SEARCHABLE_IMAGE}
* @return this Builder instance to add any additional parameters
*/
public Builder withOCRType(OCRSupportedType ocrSupportedType) {
ObjectUtil.requireNonNull(ocrSupportedType, String.format(CustomErrorMessages.GENERIC_CAN_NOT_BE_NULL,
"OCR Type"));
this.ocrType = ocrSupportedType;
return this;
}
/**
* Returns a new {@link OCRParams} instance built from the current state of this builder.
*
* @return a new {@code OCRParams} instance
*/
public OCRParams build() {
return new OCRParams(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy