【问题标题】:RazorPDF - How to set background-color for some tags like cell, paragraph etcRazorPDF - 如何为单元格、段落等标签设置背景颜色
【发布时间】:2013-09-16 07:42:02
【问题描述】:

我只是想用 RazorPDF 创建一个简单的 xml 布局,但我找不到任何方法来为某些标签设置背景颜色。

这是我尝试过的,

<paragraph style="background-color:red">
   <chunk bgcolor="red">sampletext</chunk>
</paragraph>

我的动作很简单,

public ActionResult Pdf() 
{
     return new PdfResult();
}

【问题讨论】:

    标签: xml asp.net-mvc itextsharp background-color razorpdf


    【解决方案1】:

    如果使用表格,则 backgroundcolor="#808080" 属性设置背景色,而 style="color:blue" 或 red="0" green="0" blue="255" 设置文本颜色。

    <table width="100%" cellpadding="1.0" cellspacing="1.0">
    <row>
        <cell backgroundcolor="#FFFF00" borderwidth="0.5" left="true" right="true" top="true" bottom="true" size="12.0">
            <chunk style="font-family:Times;font-weight:bold;font-size:9pt">
                Customer
            </chunk>
        </cell>
        <cell backgroundcolor="#FFFF00" borderwidth="0.5" left="true" right="true" top="true" bottom="true" size="12.0">
            <chunk style="font-family:Times;font-weight:bold;font-size:9pt;color:blue">
                Customer
            </chunk>
        </cell>
        <cell backgroundcolor="#FFFF00" borderwidth="0.5" left="true" right="true" top="true" bottom="true" size="12.0">
            <chunk red="0" green="0" blue="255" style="font-family:Times;font-weight:bold;font-size:9pt">
                Customer
            </chunk>
        </cell>
    </row></table>
    

    【讨论】:

      【解决方案2】:
          <paragraph  style="font-family:Helvetica;font-size:14; border:1px" align="center">
              <chunk red="0" green="0" blue="255" >@ViewBag.Title</chunk>
          </paragraph>
      

      【讨论】:

      • 这只会改变字体颜色,而不是背景颜色。请在此处发布之前检查您的答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-21
      • 2017-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多