Source:
<code>public static void main(final String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .apiKey(new AzureKeyCredential("{api_key}")) .endpoint("https://{endpoint}.cognitiveservices.azure.com/") .buildClient(); File sourceFile = new File("../../test/resources/sample-files/layout1.jpg"); byte[] fileContent = Files.readAllBytes(sourceFile.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); SyncPoller<OperationResult, IterableStream<FormPage>> recognizeLayoutPoller = <START> client.beginRecognizeContent(targetStream, sourceFile.length(), FormContentType.IMAGE_JPEG); <END> IterableStream<FormPage> layoutPageResults = recognizeLayoutPoller.getFinalResult(); layoutPageResults.forEach(formPage -> { System.out.println("----Recognizing content ----"); System.out.printf("Has width: %s and height: %s, measured with unit: %s%n", formPage.getWidth(), formPage.getHeight(), formPage.getUnit()); formPage.getTables().forEach(formTable -> { System.out.printf("Table has %s rows and %s columns.%n", formTable.getRowCount(), formTable.getColumnCount()); formTable.getCells().forEach(formTableCell -> { final StringBuilder boundingBoxStr = new StringBuilder(); if (formTableCell.getBoundingBox() != null) { formTableCell.getBoundingBox().getPoints().forEach(point -> boundingBoxStr.append(String.format("[%s, %s]", point.getX(), point.getY()))); } System.out.printf("Cell has text %s, within bounding box %s.%n", formTableCell.getText(), boundingBoxStr); }); System.out.println(); }); }); }</code><technical_language>I thought java automatic content type detection. If so, pass content type users</technical_language>

Target:
public static void main(final String[] args) throws IOException { FormRecognizerClient client = new FormRecognizerClientBuilder() .apiKey(new AzureKeyCredential("{api_key}")) .endpoint("https://{endpoint}.cognitiveservices.azure.com/") .buildClient(); File sourceFile = new File("/sample-forms/forms/layout1.jpg"); byte[] fileContent = Files.readAllBytes(sourceFile.toPath()); InputStream targetStream = new ByteArrayInputStream(fileContent); SyncPoller<OperationResult, IterableStream<FormPage>> recognizeLayoutPoller = client.beginRecognizeContent(targetStream, sourceFile.length(), FormContentType.IMAGE_JPEG); IterableStream<FormPage> layoutPageResults = recognizeLayoutPoller.getFinalResult(); layoutPageResults.forEach(formPage -> { System.out.println("----Recognizing content ----"); System.out.printf("Has width: %s and height: %s, measured with unit: %s%n", formPage.getWidth(), formPage.getHeight(), formPage.getUnit()); formPage.getTables().forEach(formTable -> { System.out.printf("Table has %s rows and %s columns.%n", formTable.getRowCount(), formTable.getColumnCount()); formTable.getCells().forEach(formTableCell -> { final StringBuilder boundingBoxStr = new StringBuilder(); if (formTableCell.getBoundingBox() != null) { formTableCell.getBoundingBox().getPoints().forEach(point -> boundingBoxStr.append(String.format("[%.2f, %.2f]", point.getX(), point.getY()))); } System.out.printf("Cell has text %s, within bounding box %s.%n", formTableCell.getText(), boundingBoxStr); }); System.out.println(); }); }); }