AWSTextract使用dotnetsdkC#读取特定信息的方法
创始人
2024-09-27 15:30:10
0

1.首先,安装AWS Textract的dotnet sdk C#。可以使用NuGet包管理器在Visual Studio中安装“AWSSDK.Textract”包。

2.在C#代码中,首先要引用必要的命名空间:

using Amazon.Textract; using Amazon.Textract.Model;

3.创建一个AmazonTextractClient客户端对象,以便访问AWS Textract:

AmazonTextractClient client = new AmazonTextractClient();

4.构造一个DetectDocumentTextRequest对象,指定要检测文档中的哪些信息:

DetectDocumentTextRequest request = new DetectDocumentTextRequest { Document = new Document { S3Object = new S3Object { Bucket = "my-bucket", Name = "sample-document.pdf" } } };

5.调用AWS Textract的DetectDocumentText方法并获取响应结果:

DetectDocumentTextResponse response = client.DetectDocumentText(request);

6.从响应结果中提取指定的信息。下面的代码示例演示如何获取文档中所有表格单元格的值:

foreach (Block block in response.Blocks) { if (block.BlockType == BlockType.TABLE_CELL) { string cellText = ""; foreach (Relationship relationship in block.Relationships) { if (relationship.Type == "CHILD") { foreach (string id in relationship.Ids) { Block cell = response.Blocks.Find(b => b.Id == id); if (cell.BlockType == BlockType.WORD || cell.BlockType == BlockType.SELECTION_ELEMENT) { cellText += cell.Text + " "; } } } } Console.WriteLine(cellText); } }

通过以上步骤,您可以使用AWS Textract的dotnet sdk C#读取指定的文档信息。

相关内容

热门资讯

wepokeai机器人(透视)... wepokeai机器人(透视)wepoke有没有玄学(详细辅助新2025版)确实是有挂(可靠辅助德之...
wepoke模拟器(透视)we... wepoke模拟器(透视)wepoke软件透明功能实现方法(详细辅助教你教程)好像是真的有挂(科普插...
wepoke辅助德之星(透视)... wepoke辅助德之星(透视)wepooke app系统规律(详细辅助攻略方法)真是是有挂(教你有辅...
wepoke有辅助挂(透视)w... wepoke有辅助挂(透视)wepoke有辅助挂吗(详细辅助科技教程)一直是有挂(教你透视挂)1、让...
wepoke辅助有挂(透视)w... wepoke辅助有挂(透视)wepoke人有挂吗(详细辅助可靠技巧)其实有挂(了解辅助)1.wepo...
wepoke插件(透视)wep... wepoke插件(透视)wepoke软件收费是真的吗(详细辅助辅助教程)其实真的是有挂(专业模拟器)...
wepoke辅助德之星(透视)... wepoke辅助德之星(透视)wopoker辅助(详细辅助新2025教程)真是真的有挂(玩家ai机器...
we辅助poker德之星(透视... we辅助poker德之星(透视)wepoke辅助挂在哪开(详细辅助新2025版)确实是真的有挂(大神...
wepoke黑科技(透视)we... wepoke黑科技(透视)wepoke挂真的假的(详细辅助揭秘攻略)竟然存在有挂(攻略计算辅助)1、...
wepoke智能ai(透视)w... wepoke智能ai(透视)wepower让系统发好牌(详细辅助教你攻略)真是真的有挂(详细有挂)1...