HTML
JPG
PDF
XML
DOCX
PDF
如何通过 Cloud .NET SDK 从 PDF 页面提取表格
为了通过 Cloud .NET SDK 从 PDF 页面提取表格,我们将使用 Aspose.PDF Cloud .NET SDK 此 Cloud 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。
- 将 PDF 上传到云存储。
- 使用 GetPageTablesAsync 函数从云存储中的 PDF 页面提取表格。
- 检查响应并记录结果。
- 如果操作成功,打印表格
此示例代码展示了如何从 PDF 文档中提取页面表格
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Tables
{
public class GetTablesOnPage
{
public static async Task Extract(string documentName, int pageNumber, 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 on page from the PDF on cloud storage.
TablesRecognizedResponse response = await pdfApi.GetPageTablesAsync(documentName, pageNumber, folder: remoteFolder);
// Checks the response and logs the result.
if (response == null)
Console.WriteLine("GetTablesOnPage(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetTablesOnPage(): Failed to extract tables from the document.");
else
{ // If the operation was successful, print the tables or make some other actions
Console.WriteLine("GetTablesOnPage(): All tables on '{0}' page successfully extracted from the document '{1}.", pageNumber, 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 文件中并测试功能。