首页 > 解决方案 > 如何在 C# 中使用 Google Vision API 提取 PDF 文本

问题描述

我想使用 Google Vision 将 PDF 提取到文本/表格中。我的 PDF 包含一个我要提取的表格(BlockType= 表格)。

我不确定如何在 C# 中做到这一点。

我安装了Google.Cloud.Vision.APINuGet 并尝试使用该DetectTextDocument方法,但它似乎只接收图像。

var client = new ImageAnnotatorClientBuilder
{
    CredentialsPath = @"myjsonfile.json"
}.Build();

Image image = Image.FromUri("https://storage.cloud.google.com/pathtomyfile.pdf");

TextAnnotation response = client.DetectDocumentText(image); // Getting error for a bad image.

然后我尝试查找任何文件方法并找到了BatchAnnotateFilesAsync但我不确定如何构建BatchAnnotateFilesRequest它需要的对象并且在C#.

谁能帮我弄清楚如何将PDF文档提取为表格块类型的文本?

提前致谢。

标签: c#pdf.net-coreocrgoogle-vision

解决方案


推荐阅读