【问题标题】:Define foreground color of a itextsharp table cell定义 itextsharp 表格单元格的前景色
【发布时间】:2011-04-27 15:02:11
【问题描述】:

我有一个 iTextSharp.text.Table 并尝试更改前景文本颜色。但是 Cell 对象上没有定义颜色的方法。有谁知道,我可以在哪里调整颜色?

【问题讨论】:

    标签: c# itextsharp


    【解决方案1】:

    试试下面的

        var FontColour = new BaseColor(31, 73, 125);
        var MyFont = FontFactory.GetFont("Times New Roman", 11, FontColour );
        table.AddCell(new Paragraph("My Text", MyFont));
    

    【讨论】:

    • 是的。前景文本颜色由高级文本布局代码的字体定义。当您开始直接使用 PdfContentByte 时,字体和颜色会分开,但直到那时。
    【解决方案2】:

    LnDCobras 的回答效果很好。

    我的最终解决方案如下:

    Font font = new Font(Font.HELVETICA, 11, new Color(255, 0, 0));
    Chunk chunk = new Chunk("my Text", font);
    Cell cell = new Cell(chunk);
    
    table.AddCell(cell);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-06
      • 1970-01-01
      • 2013-08-20
      • 2012-07-10
      相关资源
      最近更新 更多