[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-842d12a6-9cf1-42cc-945b-5f75478bc02a":3,"$f3Bae-QN4uiG9yX5e61baBznKjSLHZ7Pv8XRqG99Lq4w":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"842d12a6-9cf1-42cc-945b-5f75478bc02a","azure-ai-formrecognizer-java","使用Azure AI文档智能SDK for Java构建文档分析应用程序。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-formrecognizer-java\ndescription: \"Build document analysis applications using the Azure AI Document Intelligence SDK for Java.\"\nrisk: unknown\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# Azure Document Intelligence (Form Recognizer) SDK for Java\n\nBuild document analysis applications using the Azure AI Document Intelligence SDK for Java.\n\n## Installation\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.azure\u003C\u002FgroupId>\n    \u003CartifactId>azure-ai-formrecognizer\u003C\u002FartifactId>\n    \u003Cversion>4.2.0-beta.1\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n## Client Creation\n\n### DocumentAnalysisClient\n\n```java\nimport com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient;\nimport com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClientBuilder;\nimport com.azure.core.credential.AzureKeyCredential;\n\nDocumentAnalysisClient client = new DocumentAnalysisClientBuilder()\n    .credential(new AzureKeyCredential(\"{key}\"))\n    .endpoint(\"{endpoint}\")\n    .buildClient();\n```\n\n### DocumentModelAdministrationClient\n\n```java\nimport com.azure.ai.formrecognizer.documentanalysis.administration.DocumentModelAdministrationClient;\nimport com.azure.ai.formrecognizer.documentanalysis.administration.DocumentModelAdministrationClientBuilder;\n\nDocumentModelAdministrationClient adminClient = new DocumentModelAdministrationClientBuilder()\n    .credential(new AzureKeyCredential(\"{key}\"))\n    .endpoint(\"{endpoint}\")\n    .buildClient();\n```\n\n### With DefaultAzureCredential\n\n```java\nimport com.azure.identity.DefaultAzureCredentialBuilder;\n\nDocumentAnalysisClient client = new DocumentAnalysisClientBuilder()\n    .endpoint(\"{endpoint}\")\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .buildClient();\n```\n\n## Prebuilt Models\n\n| Model ID | Purpose |\n|----------|---------|\n| `prebuilt-layout` | Extract text, tables, selection marks |\n| `prebuilt-document` | General document with key-value pairs |\n| `prebuilt-receipt` | Receipt data extraction |\n| `prebuilt-invoice` | Invoice field extraction |\n| `prebuilt-businessCard` | Business card parsing |\n| `prebuilt-idDocument` | ID document (passport, license) |\n| `prebuilt-tax.us.w2` | US W2 tax forms |\n\n## Core Patterns\n\n### Extract Layout\n\n```java\nimport com.azure.ai.formrecognizer.documentanalysis.models.*;\nimport com.azure.core.util.BinaryData;\nimport com.azure.core.util.polling.SyncPoller;\nimport java.io.File;\n\nFile document = new File(\"document.pdf\");\nBinaryData documentData = BinaryData.fromFile(document.toPath());\n\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginAnalyzeDocument(\"prebuilt-layout\", documentData);\n\nAnalyzeResult result = poller.getFinalResult();\n\n\u002F\u002F Process pages\nfor (DocumentPage page : result.getPages()) {\n    System.out.printf(\"Page %d: %.2f x %.2f %s%n\",\n        page.getPageNumber(),\n        page.getWidth(),\n        page.getHeight(),\n        page.getUnit());\n    \n    \u002F\u002F Lines\n    for (DocumentLine line : page.getLines()) {\n        System.out.println(\"Line: \" + line.getContent());\n    }\n    \n    \u002F\u002F Selection marks (checkboxes)\n    for (DocumentSelectionMark mark : page.getSelectionMarks()) {\n        System.out.printf(\"Checkbox: %s (confidence: %.2f)%n\",\n            mark.getSelectionMarkState(),\n            mark.getConfidence());\n    }\n}\n\n\u002F\u002F Tables\nfor (DocumentTable table : result.getTables()) {\n    System.out.printf(\"Table: %d rows x %d columns%n\",\n        table.getRowCount(),\n        table.getColumnCount());\n    \n    for (DocumentTableCell cell : table.getCells()) {\n        System.out.printf(\"Cell[%d,%d]: %s%n\",\n            cell.getRowIndex(),\n            cell.getColumnIndex(),\n            cell.getContent());\n    }\n}\n```\n\n### Analyze from URL\n\n```java\nString documentUrl = \"https:\u002F\u002Fexample.com\u002Finvoice.pdf\";\n\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginAnalyzeDocumentFromUrl(\"prebuilt-invoice\", documentUrl);\n\nAnalyzeResult result = poller.getFinalResult();\n```\n\n### Analyze Receipt\n\n```java\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginAnalyzeDocumentFromUrl(\"prebuilt-receipt\", receiptUrl);\n\nAnalyzeResult result = poller.getFinalResult();\n\nfor (AnalyzedDocument doc : result.getDocuments()) {\n    Map\u003CString, DocumentField> fields = doc.getFields();\n    \n    DocumentField merchantName = fields.get(\"MerchantName\");\n    if (merchantName != null && merchantName.getType() == DocumentFieldType.STRING) {\n        System.out.printf(\"Merchant: %s (confidence: %.2f)%n\",\n            merchantName.getValueAsString(),\n            merchantName.getConfidence());\n    }\n    \n    DocumentField transactionDate = fields.get(\"TransactionDate\");\n    if (transactionDate != null && transactionDate.getType() == DocumentFieldType.DATE) {\n        System.out.printf(\"Date: %s%n\", transactionDate.getValueAsDate());\n    }\n    \n    DocumentField items = fields.get(\"Items\");\n    if (items != null && items.getType() == DocumentFieldType.LIST) {\n        for (DocumentField item : items.getValueAsList()) {\n            Map\u003CString, DocumentField> itemFields = item.getValueAsMap();\n            System.out.printf(\"Item: %s, Price: %.2f%n\",\n                itemFields.get(\"Name\").getValueAsString(),\n                itemFields.get(\"Price\").getValueAsDouble());\n        }\n    }\n}\n```\n\n### General Document Analysis\n\n```java\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginAnalyzeDocumentFromUrl(\"prebuilt-document\", documentUrl);\n\nAnalyzeResult result = poller.getFinalResult();\n\n\u002F\u002F Key-value pairs\nfor (DocumentKeyValuePair kvp : result.getKeyValuePairs()) {\n    System.out.printf(\"Key: %s => Value: %s%n\",\n        kvp.getKey().getContent(),\n        kvp.getValue() != null ? kvp.getValue().getContent() : \"null\");\n}\n```\n\n## Custom Models\n\n### Build Custom Model\n\n```java\nimport com.azure.ai.formrecognizer.documentanalysis.administration.models.*;\n\nString blobContainerUrl = \"{SAS_URL_of_training_data}\";\nString prefix = \"training-docs\u002F\";\n\nSyncPoller\u003COperationResult, DocumentModelDetails> poller = adminClient.beginBuildDocumentModel(\n    blobContainerUrl,\n    DocumentModelBuildMode.TEMPLATE,\n    prefix,\n    new BuildDocumentModelOptions()\n        .setModelId(\"my-custom-model\")\n        .setDescription(\"Custom invoice model\"),\n    Context.NONE);\n\nDocumentModelDetails model = poller.getFinalResult();\n\nSystem.out.println(\"Model ID: \" + model.getModelId());\nSystem.out.println(\"Created: \" + model.getCreatedOn());\n\nmodel.getDocumentTypes().forEach((docType, details) -> {\n    System.out.println(\"Document type: \" + docType);\n    details.getFieldSchema().forEach((field, schema) -> {\n        System.out.printf(\"  Field: %s (%s)%n\", field, schema.getType());\n    });\n});\n```\n\n### Analyze with Custom Model\n\n```java\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginAnalyzeDocumentFromUrl(\"my-custom-model\", documentUrl);\n\nAnalyzeResult result = poller.getFinalResult();\n\nfor (AnalyzedDocument doc : result.getDocuments()) {\n    System.out.printf(\"Document type: %s (confidence: %.2f)%n\",\n        doc.getDocType(),\n        doc.getConfidence());\n    \n    doc.getFields().forEach((name, field) -> {\n        System.out.printf(\"Field '%s': %s (confidence: %.2f)%n\",\n            name,\n            field.getContent(),\n            field.getConfidence());\n    });\n}\n```\n\n### Compose Models\n\n```java\nList\u003CString> modelIds = Arrays.asList(\"model-1\", \"model-2\", \"model-3\");\n\nSyncPoller\u003COperationResult, DocumentModelDetails> poller = \n    adminClient.beginComposeDocumentModel(\n        modelIds,\n        new ComposeDocumentModelOptions()\n            .setModelId(\"composed-model\")\n            .setDescription(\"Composed from multiple models\"));\n\nDocumentModelDetails composedModel = poller.getFinalResult();\n```\n\n### Manage Models\n\n```java\n\u002F\u002F List models\nPagedIterable\u003CDocumentModelSummary> models = adminClient.listDocumentModels();\nfor (DocumentModelSummary summary : models) {\n    System.out.printf(\"Model: %s, Created: %s%n\",\n        summary.getModelId(),\n        summary.getCreatedOn());\n}\n\n\u002F\u002F Get model details\nDocumentModelDetails model = adminClient.getDocumentModel(\"model-id\");\n\n\u002F\u002F Delete model\nadminClient.deleteDocumentModel(\"model-id\");\n\n\u002F\u002F Check resource limits\nResourceDetails resources = adminClient.getResourceDetails();\nSystem.out.printf(\"Models: %d \u002F %d%n\",\n    resources.getCustomDocumentModelCount(),\n    resources.getCustomDocumentModelLimit());\n```\n\n## Document Classification\n\n### Build Classifier\n\n```java\nMap\u003CString, ClassifierDocumentTypeDetails> docTypes = new HashMap\u003C>();\ndocTypes.put(\"invoice\", new ClassifierDocumentTypeDetails()\n    .setAzureBlobSource(new AzureBlobContentSource(containerUrl).setPrefix(\"invoices\u002F\")));\ndocTypes.put(\"receipt\", new ClassifierDocumentTypeDetails()\n    .setAzureBlobSource(new AzureBlobContentSource(containerUrl).setPrefix(\"receipts\u002F\")));\n\nSyncPoller\u003COperationResult, DocumentClassifierDetails> poller = \n    adminClient.beginBuildDocumentClassifier(docTypes,\n        new BuildDocumentClassifierOptions().setClassifierId(\"my-classifier\"));\n\nDocumentClassifierDetails classifier = poller.getFinalResult();\n```\n\n### Classify Document\n\n```java\nSyncPoller\u003COperationResult, AnalyzeResult> poller = \n    client.beginClassifyDocumentFromUrl(\"my-classifier\", documentUrl, Context.NONE);\n\nAnalyzeResult result = poller.getFinalResult();\n\nfor (AnalyzedDocument doc : result.getDocuments()) {\n    System.out.printf(\"Classified as: %s (confidence: %.2f)%n\",\n        doc.getDocType(),\n        doc.getConfidence());\n}\n```\n\n## Error Handling\n\n```java\nimport com.azure.core.exception.HttpResponseException;\n\ntry {\n    client.beginAnalyzeDocumentFromUrl(\"prebuilt-receipt\", \"invalid-url\");\n} catch (HttpResponseException e) {\n    System.out.println(\"Status: \" + e.getResponse().getStatusCode());\n    System.out.println(\"Error: \" + e.getMessage());\n}\n```\n\n## Environment Variables\n\n```bash\nFORM_RECOGNIZER_ENDPOINT=https:\u002F\u002F\u003Cresource>.cognitiveservices.azure.com\u002F\nFORM_RECOGNIZER_KEY=\u003Cyour-api-key>\n```\n\n## Trigger Phrases\n\n- \"document intelligence Java\"\n- \"form recognizer SDK\"\n- \"extract text from PDF\"\n- \"OCR document Java\"\n- \"analyze invoice receipt\"\n- \"custom document model\"\n- \"document classification\"\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,65,624,"2026-05-16 13:05:15",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"7786cd2a-04ad-4e28-aed0-d3b6d132c23d","1.0.0","azure-ai-formrecognizer-java.zip",3080,"uploads\u002Fskills\u002F842d12a6-9cf1-42cc-945b-5f75478bc02a\u002Fazure-ai-formrecognizer-java.zip","70b09386dda43f136a96883beb1749fe24c2c082791a2f1dabba2977130e3c0f","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":10567}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]