HTML
JPG
PDF
XML
DOCX
PDF
如何使用Cloud .NET SDK按名称解析PDF文档以提取文本
为了通过Cloud .NET SDK按名称解析PDF文档以提取文本,我们将使用 Aspose.PDF Cloud .NET SDK 此Cloud .NET SDK允许您轻松构建基于云的PDF创建、编辑和转换应用程序,支持C#、ASP.NET或其他.NET语言用于各种云平台。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您还可以使用以下命令从包管理器控制台中执行安装。
包管理器控制台命令
PM> Install-Package Aspose.Pdf-Cloud
使用.NET SDK按名称解析PDF以提取文本的步骤
Aspose.PDF Cloud开发人员可以轻松地按名称解析PDF文档以提取文本。开发人员只需几行代码。
- 使用您的应用程序密钥和密钥创建一个新的配置对象
- 创建一个对象以连接到Cloud API
- 上传您的文档文件
- 使用GetTextBoxFieldAsync函数在云存储中按名称解析PDF文档以提取文本
- 检查响应并记录结果
- 如果操作成功,打印提取的文本
此示例代码展示了按名称解析PDF文档以提取文本
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Parser
{
public class GetTextBox
{
public static async Task Extract(string documentName, string fieldName, string remoteFolder)
{
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
pdfApi = new PdfApi(AppSecret, AppSid);
using (var file = File.OpenRead(Path.Combine(localFolder, documentName)))
{ // Upload the local PDF to cloud storage folder name.
FilesUploadResult uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, documentName), documentName);
Console.WriteLine(uploadResponse.Uploaded[0]);
}
// Parse PDF to extract text box by name in cloud storage.
TextBoxFieldResponse response = await pdfApi.GetTextBoxFieldAsync(documentName, fieldName, folder: remoteFolder);
// Checks the response and logs the result.
if (response == null)
Console.WriteLine("GetTextBox(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetTextBox(): Failed to receive TextBox fields from the document.");
else
{ // Show text box.
Console.WriteLine("GetTextBox(): TextBox field '{0}' successfully received from the document '{1}.", fieldName, documentName);
Console.WriteLine(response.Field.ToString());
}
}
}
}
通过.NET SDK处理PDF中的文本解析
通过按名称解析PDF文档进行文本提取,您可以根据需要修改TextBox字段的内容。这在节省时间和减少手动工作量的同时保持了文本在文档中的位置。 使用Aspose.PDF Cloud .NET SDK按名称解析PDF文档以提取文本。
使用我们的.NET SDK,您可以
- 以文本或图像格式添加PDF文档的页眉和页脚。
- 向PDF文档添加表格和文本或图像印章。
- 将多个PDF文档附加到现有文件。
- 处理PDF附件、注释和表单字段。
- 对PDF文档进行加密或解密并设置密码。
- 从页面或整个PDF文档中删除所有印章和表格。
- 根据ID从PDF文档中删除特定印章或表格。
- 替换PDF页面或整个文档中的单个或多个实例的文本。
- 广泛支持将PDF文档转换为各种其他文件格式。
- 提取PDF文件的各种元素并优化PDF文档。
- 您可以尝试我们的免费应用来测试功能。