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 表格,只需几行代码。
- 将文件上传到云存储
- 定义表格外观
- 定义表格内容
- 将表格添加到 PDF 中
- 下载更新后的文件
此示例代码展示了如何将表格添加到 PDF 文档中
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Tables
{
public class TableCreate
{
public static Table New()
{
int num_of_cols = 5;
int num_of_rows = 5;
TextState header_text_state = new TextState(
Font: "Arial Bold",
FontSize: 11,
ForegroundColor: new Color(A: 255, R: 255, G: 255, B: 255),
FontStyle: FontStyles.Bold);
TextState common_text_state = new TextState(
Font: "Arial Bold",
FontSize: 11,
ForegroundColor: new Color(A: 255, R: 112, G: 112, B: 112),
FontStyle: FontStyles.Regular);
string col_widths = string.Empty;
for (int col_index = 0; col_index < num_of_cols; col_index++)
{
col_widths += " 70";
}
List<Row> table_rows = new List<Row>();
GraphInfo border_table_border = new GraphInfo(
Color: new Color(A: 255, R: 0, G: 255, B: 0),
LineWidth: 0.5);
for (int row_index = 0; row_index < num_of_rows; row_index++)
{
List<Cell> row_cells = new List<Cell>();
for (int col_index = 0; col_index < num_of_cols; col_index++)
{
Cell cell = new Cell(DefaultCellTextState: common_text_state, Paragraphs: new List<TextRect>());
if (row_index == 0)
{ // header cells
cell.BackgroundColor = new Color(A: 255, R: 128, G: 128, B: 128);
cell.DefaultCellTextState = header_text_state;
}
else
{
cell.BackgroundColor = new Color(A: 255, R: 255, G: 255, B: 255);
cell.DefaultCellTextState = common_text_state;
};
TextRect text_rect = new TextRect();
if (row_index == 0)
{
text_rect.Text = "header #" + col_index.ToString();
}
else
text_rect.Text = string.Format("value '{0}', '{1}'", row_index, col_index);
cell.Paragraphs.Add(text_rect);
row_cells.Add(cell);
}
Row row = new Row(Cells: row_cells);
table_rows.Add(row);
}
Table table = new Table(Left: 150, Top: 250, ColumnWidths: col_widths, Rows: table_rows);
table.DefaultCellBorder = new BorderInfo(
Top: border_table_border,
Right: border_table_border,
Bottom: border_table_border,
Left: border_table_border,
RoundedBorderRadius: 2);
return table;
}
}
}
在 PDF 中处理表格
表格为系统地呈现数据提供了一种结构化格式,使读者更容易理解和分析信息。它们还增强了文档的视觉吸引力,增加了专业性和组织性。在处理数字或对比数据时,表格通过将相关信息分组在易于阅读的格式中提高了清晰度。此外,表格可以包含实时或动态生成的内容,如数据库或分析仪表板中的数据。 使用 Aspose.PDF Cloud Node.js SDK 为 PDF 文档创建带有扩展属性的表格。
使用我们的 .NET 库,您可以:
- 以文本或图像格式添加 PDF 文档的页眉和页脚。
- 将表格和印章(文本或图像)添加到 PDF 文档。
- 将多个 PDF 文档追加到现有文件。
- 处理 PDF 附件、注释和表单字段。
- 对 PDF 文档进行加密或解密并设置密码。
- 删除页面或整个 PDF 文档中的所有印章和表格。
- 根据 ID 删除 PDF 文档中的特定印章或表格。
- 替换 PDF 页面或整个文档中的单个或多个文本实例。
- 支持将 PDF 文档转换为多种其他文件格式。
- 提取 PDF 文件的各种元素并优化 PDF 文档。
- 您可以尝试我们的免费应用,在线将表格提取到 PDF 文件中并测试功能。