Skip to main content 首页 创作者 anhvu1107 all-agent-skill azure-ai-formrecognizer-java
azure-ai-formrecognizer-java ALWAYS use this when the request matches Azure AI Formrecognizer Java: Build document analysis applications using the Azure AI Document Intelligence SDK for Java.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Anhvu1107/all-agent-skill --skill azure-ai-formrecognizer-java命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... ALWAYS use this when the user mentions 10 Andruia Skill Smith, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on 10 Andruia Skill Smith; scope: Ingeniero de Sistemas de Andru.ia. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.
name azure-ai-formrecognizer-java description ALWAYS use this when the request matches Azure AI Formrecognizer Java: Build document analysis applications using the Azure AI Document Intelligence SDK for Java.
Azure Document Intelligence (Form Recognizer) SDK for Java
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Build document analysis applications using the Azure AI Document Intelligence SDK for Java.
Installation
<dependency >
<groupId > com.azure</groupId >
<artifactId > azure-ai-formrecognizer</artifactId >
<version > 4.2.0-beta.1</version >
</dependency >
Client Creation
DocumentAnalysisClient
import com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient;
import com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClientBuilder;
import com.azure.core.credential.AzureKeyCredential;
DocumentAnalysisClient ()
.credential( ( ))
.endpoint( )
.buildClient();
client
=
new
DocumentAnalysisClientBuilder
new
AzureKeyCredential
"{key}"
"{endpoint}"
DocumentModelAdministrationClient import com.azure.ai.formrecognizer.documentanalysis.administration.DocumentModelAdministrationClient;
import com.azure.ai.formrecognizer.documentanalysis.administration.DocumentModelAdministrationClientBuilder;
DocumentModelAdministrationClient adminClient = new DocumentModelAdministrationClientBuilder ()
.credential(new AzureKeyCredential ("{key}" ))
.endpoint("{endpoint}" )
.buildClient();
With DefaultAzureCredential import com.azure.identity.DefaultAzureCredentialBuilder;
DocumentAnalysisClient client = new DocumentAnalysisClientBuilder ()
.endpoint("{endpoint}" )
.credential(new DefaultAzureCredentialBuilder ().build())
.buildClient();
Prebuilt Models Model ID Purpose prebuilt-layoutExtract text, tables, selection marks prebuilt-documentGeneral document with key-value pairs prebuilt-receiptReceipt data extraction prebuilt-invoiceInvoice field extraction prebuilt-businessCardBusiness card parsing prebuilt-idDocumentID document (passport, license) prebuilt-tax.us.w2US W2 tax forms
Core Patterns
Extract Layout import com.azure.ai.formrecognizer.documentanalysis.models.*;
import com.azure.core.util.BinaryData;
import com.azure.core.util.polling.SyncPoller;
import java.io.File;
File document = new File ("document.pdf" );
BinaryData documentData = BinaryData.fromFile(document.toPath());
SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginAnalyzeDocument("prebuilt-layout" , documentData);
AnalyzeResult result = poller.getFinalResult();
for (DocumentPage page : result.getPages()) {
System.out.printf("Page %d: %.2f x %.2f %s%n" ,
page.getPageNumber(),
page.getWidth(),
page.getHeight(),
page.getUnit());
for (DocumentLine line : page.getLines()) {
System.out.println("Line: " + line.getContent());
}
for (DocumentSelectionMark mark : page.getSelectionMarks()) {
System.out.printf("Checkbox: %s (confidence: %.2f)%n" ,
mark.getSelectionMarkState(),
mark.getConfidence());
}
}
for (DocumentTable table : result.getTables()) {
System.out.printf("Table: %d rows x %d columns%n" ,
table.getRowCount(),
table.getColumnCount());
for (DocumentTableCell cell : table.getCells()) {
System.out.printf("Cell[%d,%d]: %s%n" ,
cell.getRowIndex(),
cell.getColumnIndex(),
cell.getContent());
}
}
Analyze from URL String documentUrl = "https://example.com/invoice.pdf" ;
SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginAnalyzeDocumentFromUrl("prebuilt-invoice" , documentUrl);
AnalyzeResult result = poller.getFinalResult();
Analyze Receipt SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginAnalyzeDocumentFromUrl("prebuilt-receipt" , receiptUrl);
AnalyzeResult result = poller.getFinalResult();
for (AnalyzedDocument doc : result.getDocuments()) {
Map<String, DocumentField> fields = doc.getFields();
DocumentField merchantName = fields.get("MerchantName" );
if (merchantName != null && merchantName.getType() == DocumentFieldType.STRING) {
System.out.printf("Merchant: %s (confidence: %.2f)%n" ,
merchantName.getValueAsString(),
merchantName.getConfidence());
}
DocumentField transactionDate = fields.get("TransactionDate" );
if (transactionDate != null && transactionDate.getType() == DocumentFieldType.DATE) {
System.out.printf("Date: %s%n" , transactionDate.getValueAsDate());
}
DocumentField items = fields.get("Items" );
if (items != null && items.getType() == DocumentFieldType.LIST) {
for (DocumentField item : items.getValueAsList()) {
Map<String, DocumentField> itemFields = item.getValueAsMap();
System.out.printf("Item: %s, Price: %.2f%n" ,
itemFields.get("Name" ).getValueAsString(),
itemFields.get("Price" ).getValueAsDouble());
}
}
}
General Document Analysis SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginAnalyzeDocumentFromUrl("prebuilt-document" , documentUrl);
AnalyzeResult result = poller.getFinalResult();
for (DocumentKeyValuePair kvp : result.getKeyValuePairs()) {
System.out.printf("Key: %s => Value: %s%n" ,
kvp.getKey().getContent(),
kvp.getValue() != null ? kvp.getValue().getContent() : "null" );
}
Custom Models
Build Custom Model import com.azure.ai.formrecognizer.documentanalysis.administration.models.*;
String blobContainerUrl = "{SAS_URL_of_training_data}" ;
String prefix = "training-docs/" ;
SyncPoller<OperationResult, DocumentModelDetails> poller = adminClient.beginBuildDocumentModel(
blobContainerUrl,
DocumentModelBuildMode.TEMPLATE,
prefix,
new BuildDocumentModelOptions ()
.setModelId("my-custom-model" )
.setDescription("Custom invoice model" ),
Context.NONE);
DocumentModelDetails model = poller.getFinalResult();
System.out.println("Model ID: " + model.getModelId());
System.out.println("Created: " + model.getCreatedOn());
model.getDocumentTypes().forEach((docType, details) -> {
System.out.println("Document type: " + docType);
details.getFieldSchema().forEach((field, schema) -> {
System.out.printf(" Field: %s (%s)%n" , field, schema.getType());
});
});
Analyze with Custom Model SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginAnalyzeDocumentFromUrl("my-custom-model" , documentUrl);
AnalyzeResult result = poller.getFinalResult();
for (AnalyzedDocument doc : result.getDocuments()) {
System.out.printf("Document type: %s (confidence: %.2f)%n" ,
doc.getDocType(),
doc.getConfidence());
doc.getFields().forEach((name, field) -> {
System.out.printf("Field '%s': %s (confidence: %.2f)%n" ,
name,
field.getContent(),
field.getConfidence());
});
}
Compose Models List<String> modelIds = Arrays.asList("model-1" , "model-2" , "model-3" );
SyncPoller<OperationResult, DocumentModelDetails> poller =
adminClient.beginComposeDocumentModel(
modelIds,
new ComposeDocumentModelOptions ()
.setModelId("composed-model" )
.setDescription("Composed from multiple models" ));
DocumentModelDetails composedModel = poller.getFinalResult();
Manage Models
PagedIterable<DocumentModelSummary> models = adminClient.listDocumentModels();
for (DocumentModelSummary summary : models) {
System.out.printf("Model: %s, Created: %s%n" ,
summary.getModelId(),
summary.getCreatedOn());
}
DocumentModelDetails model = adminClient.getDocumentModel("model-id" );
adminClient.deleteDocumentModel("model-id" );
ResourceDetails resources = adminClient.getResourceDetails();
System.out.printf("Models: %d / %d%n" ,
resources.getCustomDocumentModelCount(),
resources.getCustomDocumentModelLimit());
Document Classification
Build Classifier Map<String, ClassifierDocumentTypeDetails> docTypes = new HashMap <>();
docTypes.put("invoice" , new ClassifierDocumentTypeDetails ()
.setAzureBlobSource(new AzureBlobContentSource (containerUrl).setPrefix("invoices/" )));
docTypes.put("receipt" , new ClassifierDocumentTypeDetails ()
.setAzureBlobSource(new AzureBlobContentSource (containerUrl).setPrefix("receipts/" )));
SyncPoller<OperationResult, DocumentClassifierDetails> poller =
adminClient.beginBuildDocumentClassifier(docTypes,
new BuildDocumentClassifierOptions ().setClassifierId("my-classifier" ));
DocumentClassifierDetails classifier = poller.getFinalResult();
Classify Document SyncPoller<OperationResult, AnalyzeResult> poller =
client.beginClassifyDocumentFromUrl("my-classifier" , documentUrl, Context.NONE);
AnalyzeResult result = poller.getFinalResult();
for (AnalyzedDocument doc : result.getDocuments()) {
System.out.printf("Classified as: %s (confidence: %.2f)%n" ,
doc.getDocType(),
doc.getConfidence());
}
Error Handling import com.azure.core.exception.HttpResponseException;
try {
client.beginAnalyzeDocumentFromUrl("prebuilt-receipt" , "invalid-url" );
} catch (HttpResponseException e) {
System.out.println("Status: " + e.getResponse().getStatusCode());
System.out.println("Error: " + e.getMessage());
}
Environment Variables FORM_RECOGNIZER_ENDPOINT=https://<resource>.cognitiveservices.azure.com/
FORM_RECOGNIZER_KEY=<your-api-key>
Trigger Phrases
"document intelligence Java"
"form recognizer SDK"
"extract text from PDF"
"OCR document Java"
"analyze invoice receipt"
"custom document model"
"document classification"
When to Use This skill is applicable to execute the workflow or actions described in the overview.
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.