本文整理汇总了C#中iTextSharp.text.Table.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# Table.GetRow方法的具体用法?C# Table.GetRow怎么用?C# Table.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.Table
的用法示例。
在下文中一共展示了Table.GetRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePdf
/// <summary>
/// Create a PDF representation of the table
/// </summary>
/// <param name="inputTable">
/// The <c>Table</c> to parse
/// </param>
/// <returns>
/// A PDF Table
/// </returns>
private static PdfPTable CreatePdf(Table inputTable)
{
if (inputTable.Children.Count > 0 && inputTable.Children[0] != null)
{
TableRow firstRow = inputTable.GetRow(0);
int cols = firstRow.CellCount;
var table = new PdfPTable(cols);
foreach (TableRow row in inputTable.Children)
{
if (row != null)
{
foreach (TableCell tableCell in row.Children)
{
if (tableCell != null)
{
var cell = new PdfPCell(new Paragraph(tableCell.Text))
{
Rowspan = tableCell.RowSpan,
Colspan = tableCell.ColumnSpan,
Padding = 3.0f,
HorizontalAlignment = Element.ALIGN_CENTER,
VerticalAlignment = Element.ALIGN_MIDDLE,
BorderColor = _borderColor,
BackgroundColor = _defaultBackgroundColor
};
cell.Phrase.Font.SetFamily("Helvetica");
cell.Phrase.Font.SetStyle(Font.NORMAL);
if (tableCell.HasClass(HtmlClasses.SliceKeyTitle))
{
cell.Phrase.Font.SetStyle(Font.BOLD);
cell.BackgroundColor = _keyValueBackgroundColor;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
}
else if (tableCell.HasClass(HtmlClasses.VerticalKeyTitle)
|| tableCell.HasClass(HtmlClasses.HorizontalKeyTitle))
{
cell.Phrase.Font.SetStyle(Font.BOLD);
cell.BackgroundColor = _keyValueBackgroundColor;
}
else if (tableCell.HasClass(HtmlClasses.HorizontalKeyValue)
|| tableCell.HasClass(HtmlClasses.VerticalKeyValue))
{
cell.BackgroundColor = _keyValueBackgroundColor;
}
// TODO handle this some other way
// if (td.Attr.TryGetValue("class", out clazz) && !String.IsNullOrEmpty(clazz)) {
// if ("keytitle".Contains(clazz.Substring(1))) {
// cell.Phrase.Font.SetStyle(Font.BOLD);
// cell.BackgroundColor = new BaseColor(0xDF, 0xEF, 0xFC);
// if (clazz.Contains("skeytitle")) {
// cell.HorizontalAlignment = Element.ALIGN_RIGHT;
// }
// }
// else if (clazz.Contains("keyvalue")) {
// cell.BackgroundColor = new BaseColor(0xDF, 0xEF, 0xFC);
// }
// }
table.AddCell(cell);
}
}
}
}
return table;
}
return null;
}