use of software.amazon.awssdk.services.textract.TextractClient in project aws-doc-sdk-examples by awsdocs.
the class DetectDocumentText method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <sourceDoc> \n\n" + "Where:\n" + " sourceDoc - the path where the document is located (must be an image, for example, C:/AWS/book.png). \n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String sourceDoc = args[0];
Region region = Region.US_EAST_2;
TextractClient textractClient = TextractClient.builder().region(region).build();
detectDocText(textractClient, sourceDoc);
textractClient.close();
}
use of software.amazon.awssdk.services.textract.TextractClient in project aws-doc-sdk-examples by awsdocs.
the class StartDocumentAnalysis method main.
public static void main(String[] args) {
final String usage = "\n" + "Usage:\n" + " <bucketName> <docName> \n\n" + "Where:\n" + " bucketName - the name of the Amazon S3 bucket that contains the document. \n\n" + " docName - the document name (must be an image, for example, book.png). \n";
if (args.length != 2) {
System.out.println(usage);
System.exit(1);
}
String bucketName = args[0];
String docName = args[1];
Region region = Region.US_WEST_2;
TextractClient textractClient = TextractClient.builder().region(region).build();
String jobId = startDocAnalysisS3(textractClient, bucketName, docName);
System.out.println("Getting results for job " + jobId);
String status = getJobResults(textractClient, jobId);
System.out.println("The job status is " + status);
textractClient.close();
}
use of software.amazon.awssdk.services.textract.TextractClient in project aws-doc-sdk-examples by awsdocs.
the class AnalyzeDocument method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <sourceDoc> \n\n" + "Where:\n" + " sourceDoc - the path where the document is located (must be an image, for example, C:/AWS/book.png). \n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String sourceDoc = args[0];
Region region = Region.US_EAST_2;
TextractClient textractClient = TextractClient.builder().region(region).build();
analyzeDoc(textractClient, sourceDoc);
textractClient.close();
}
use of software.amazon.awssdk.services.textract.TextractClient in project aws-doc-sdk-examples by awsdocs.
the class DetectDocumentTextS3 method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <bucketName> <docName> \n\n" + "Where:\n" + " bucketName - The name of the Amazon S3 bucket that contains the document. \n\n" + " docName - The document name (must be an image, i.e., book.png). \n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
String docName = args[1];
Region region = Region.US_WEST_2;
TextractClient textractClient = TextractClient.builder().region(region).build();
detectDocTextS3(textractClient, bucketName, docName);
textractClient.close();
}
use of software.amazon.awssdk.services.textract.TextractClient in project aws-doc-sdk-examples by awsdocs.
the class TextractService method analyzeDoc.
public String analyzeDoc(byte[] bytes) {
List myList = new ArrayList<String>();
try {
Region region = Region.US_EAST_2;
TextractClient textractClient = TextractClient.builder().region(region).build();
SdkBytes sourceBytes = SdkBytes.fromByteArray(bytes);
// Get the input Document object as bytes
Document myDoc = Document.builder().bytes(sourceBytes).build();
List<FeatureType> featureTypes = new ArrayList<FeatureType>();
featureTypes.add(FeatureType.FORMS);
featureTypes.add(FeatureType.TABLES);
AnalyzeDocumentRequest analyzeDocumentRequest = AnalyzeDocumentRequest.builder().featureTypes(featureTypes).document(myDoc).build();
AnalyzeDocumentResponse analyzeDocument = textractClient.analyzeDocument(analyzeDocumentRequest);
List<Block> docInfo = analyzeDocument.blocks();
Iterator<Block> blockIterator = docInfo.iterator();
while (blockIterator.hasNext()) {
Block block = blockIterator.next();
myList.add("The block type is " + block.blockType().toString());
}
return convertToString(toXml(myList));
} catch (TextractException e) {
System.err.println(e.getMessage());
System.exit(1);
}
return "";
}
Aggregations