HTML
JPG
PDF
XML
DOCX
PDF
如何通过云 .NET SDK 从 PDF 中提取表格
为了通过云 .NET SDK 从 PDF 中提取表格,我们将使用 Aspose.PDF Cloud .NET SDK 这个云 SDK 允许您轻松构建基于云的 PDF 创建、编辑和转换应用程序,适用于 C#、ASP.NET 或其他 .NET 语言,支持各种云平台。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您也可以在包管理器控制台中使用以下命令。
包管理器控制台命令
PM> Install-Package Aspose.Pdf-Cloud
通过 .NET SDK 从 PDF 提取表格的步骤
Aspose.PDF Cloud 开发人员可以轻松地在几行代码中从 PDF 加载和获取表格。
- 使用您的应用程序密钥和密钥创建新的 Configuration 对象。
- 创建一个对象以连接到云 API。
- 将 PDF 上传到云存储。
- 使用 GetDocumentTablesAsync 函数从云存储中的 PDF 中提取表格。
- 检查响应并记录结果。
- 如果操作成功,打印表格
此示例代码显示从 PDF 文档中提取表格
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Tables
{
public class GetTables
{
public static async Task Extract(string documentName, 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]);
}
// Get all tables from the PDF on cloud storage.
TablesRecognizedResponse response = await pdfApi.GetDocumentTablesAsync(documentName, folder: remoteFolder);
// Checks the response and logs the result.
if (response == null)
Console.WriteLine("GetTables(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetTables(): Failed to extract tables from the document.");
else
{ // If the operation was successful, print the tables or make some other actions
Console.WriteLine("GetTables(): All tables successfully extracted from the document '{0}.", documentName);
foreach (var table in response.Tables.List)
{
Console.WriteLine(table.ToString());
}
}
}
}
}
在 PDF 中处理表格
表格为系统地呈现数据提供了一种结构化格式,使读者更容易理解和分析信息。它们还增强了文档的视觉吸引力,增加了专业性和组织性。在处理数值或比较数据时,表格通过将相关信息分组为易于阅读的格式来提高清晰度。此外,表格可以包含实时或动态生成的内容,例如来自数据库或分析仪表板的数据。 使用 Aspose.PDF Cloud Node.js SDK 从 PDF 文档中获取所有表格。
使用我们的 .NET 库,您可以:
- 以文本或图像格式添加 PDF 文档的页眉和页脚。
- 向 PDF 文档添加表格和印章(文本或图像)。
- 将多个 PDF 文档附加到现有文件中。
- 处理 PDF 附件、注释和表单字段。
- 对 PDF 文档应用加密或解密并设置密码。
- 从页面或整个 PDF 文档中删除所有印章和表格。
- 按 ID 从 PDF 文档中删除特定印章或表格。
- 替换 PDF 页面或整个文档中的单个或多个文本实例。
- 广泛支持将 PDF 文档转换为各种其他文件格式。
- 提取 PDF 文件的各种元素并优化 PDF 文档。
- 您可以试用我们的免费应用 在线提取 PDF 文件中的表格并测试功能。