没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2020-05-28 09:36:59.277|阅读 692 次
概述:在本系列教程中,将为开发者带来Aspose.PDF for .NET的一系列使用教程,例如进行文档间的转换,如何标记PDF文件,如何使用表单和图表等等。本文将介绍如何设置表格的边框样式,边距和填充。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Aspose.PDF for .NET是一种高PDF处理和解析API,用于在跨平台应用程序中执行文档管理和操作任务。API可以轻松用于生成、修改、转换、渲染、保护和打印PDF文档,而无需使用Adobe Acrobat。此外,API还提供PDF压缩选项,表格创建和操作,图形和图像功能,广泛的超链接功能,印章和水印任务,扩展的安全控制和自定义字体处理。
在接下来的系列教程中,将为开发者带来Aspose.PDF for .NET的一系列使用教程,例如进行文档间的转换,如何标记PDF文件,如何使用表单和图表等等。本文将介绍如何设置表格的边框样式,边距和填充。
>>Aspose.PDF for .NET更新至最新版v20.5,欢迎下载体验。
Aspose.PDF for .NET允许开发人员在PDF文档中创建表格。而且,它们可以将边框样式,边距和单元格填充等效果应用于表格。在深入了解技术细节之前,重要的是要了解下图所示的边框,边距和填充的概念:
边框,边距和填充
在上图中,可以看到表格,行和单元格的边界重叠。使用Aspose.PDF for .NET,表格可以具有边距和单元格填充。要设置单元格的边距,我们必须设置单元格填充。
边框
要设置的边界Table,Row和Cell对象,请使用Table.Border,Row.Border和Cell.Border性能。也可以使用Table或Row类的DefaultCellBorder属性来设置单元格边框。上面讨论的所有与边框相关的属性都分配了Row该类的实例,该类是通过调用其构造函数创建的。本Row类有需要的几乎所有以自定义边框所需的参数很多重载。
边距或填充
单元格填充可以使用Tableclass的DefaultCellPaddingproperty 进行管理。所有的填充相关的属性分配的一个实例,MarginInfo大约需要的信息类Left,Right,Top和Bottom参数来创建自定义边距。在下面的示例中,单元格边框的宽度设置为0.1点,表边框的宽度设置为1点,单元格填充设置为5点。
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
// Instntiate the Document object by calling its empty constructor
Document doc = new Document();
Page page = doc.Pages.Add();
// Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
// Add the table in paragraphs collection of the desired section
page.Paragraphs.Add(tab1);
// Set with column widths of the table
tab1.ColumnWidths = "50 50 50";
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1");
row1.Cells.Add("col2");
row1.Cells.Add();
TextFragment mytext = new TextFragment("col3 with large text string");
// Row1.Cells.Add("col3 with large text string to be placed inside cell");
row1.Cells[2].Paragraphs.Add(mytext);
row1.Cells[2].IsWordWrapped = false;
// Row1.Cells[2].Paragraphs[0].FixedWidth= 80;
Aspose.Pdf.Row row2 = tab1.Rows.Add();
row2.Cells.Add("item1");
row2.Cells.Add("item2");
row2.Cells.Add("item3");
dataDir = dataDir + "MarginsOrPadding_out.pdf";
// Save the Pdf
doc.Save(dataDir);
要创建带有圆角的表,请使用BorderInfo类的RoundedBorderRadius值并将表的角样式设置为圆形。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table(); GraphInfo graph = new GraphInfo(); graph.Color = Aspose.Pdf.Color.Red; // Create a blank BorderInfo object BorderInfo bInfo = new BorderInfo(BorderSide.All, graph); // Set the border a rounder border where radius of round is 15 bInfo.RoundedBorderRadius = 15; // Set the table Corner style as Round. tab1.CornerStyle = Aspose.Pdf.BorderCornerStyle.Round; // Set the table border information tab1.Border = bInfo;
双边框
如上所述,边框可以加入Table或Cell对象。我们的用户要求我们添加一项功能,允许他们在Table和Cell对象周围添加双边框。NET 8.8.0的Aspose.PDF中添加了此功能。下面的代码段显示了如何实现此要求。
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
// Instantiate Document object
Document doc = new Document();
// Add page to PDF document
Page page = doc.Pages.Add();
// Create BorderInfo object
Aspose.Pdf.BorderInfo border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);
// Specify that Top border will be double
border.Top.IsDoubled = true;
// Specify that bottom border will be double
border.Bottom.IsDoubled = true;
// Instantiate Table object
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
// Specify Columns width information
table.ColumnWidths = "100";
// Create Row object
Aspose.Pdf.Row row = table.Rows.Add();
// Add a Table cell to cells collection of row
Aspose.Pdf.Cell cell = row.Cells.Add("some text");
// Set the border for cell object (double border)
cell.Border = border;
// Add table to paragraphs collection of Page
page.Paragraphs.Add(table);
dataDir = dataDir + "TableBorderTest_out.pdf";
// Save the PDF document
doc.Save(dataDir);
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




在使用Parasoft C/C++test执行BugDetective数据流分析时,可能会遇到用户自定义的资源API,那在这种情况下,若要判断是否存在资源问题,如资源泄露等,则需要手动配置测试配置。
大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
BarTender 标签管理系统,正是帮助企业轻松实现 GS1 标准化标签设计、编码生成与信息联动的强大工具。
Parasoft C/C++test 是一款功能强大的 C/C++ 软件测试工具,集成了静态代码分析、单元测试、集成测试和覆盖率分析等功能,单元测试作为其关键功能之一,为了适配多样化的目标部署环境,C/C++test 设计了灵活的测试结果收集机制。通过Socket通讯方式来收集单元测试结果,从而扩展其测试覆盖范围与应用场景。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营