【问题标题】:Table borders don't display with xhtml2pdfxhtml2pdf 不显示表格边框
【发布时间】:2015-07-06 02:59:17
【问题描述】:

我在 Django 中使用 xhtml2pdf 来输出一个包含多个表格的页面; html 视图完全按照我想要的方式显示,但 PDF 输出没有显示表格边框。

CSS(在模板中,未链接)是:

     body {
          font-size:11pt;
          line-height:13pt;
          font-family:Calibri,Candara,Segoe,Segoe UI,Optima,Arial,sans-serif;
      }
      table.table-bordered, table.table-bordered>thead>tr>th, table.table-bordered>tbody>tr>td {
          border-top-width: 1pt;
          border-top-style: solid;
          border-top-color: #000000;
          border-bottom-width: 1pt;
          border-bottom-style: solid;
          border-bottom-color: #000000;
          border-left-width: 1pt;
          border-left-style: solid;
          border-left-color: #000000;
          border-right-width: 1pt;
          border-right-style: solid;
          border-right-color: #000000;
          padding-top: 12pt;
          padding-right: 12pt;
          padding-bottom: 12pt;
          padding-left: 12pt;
      }
      .border-top {
          border-top-width: 1pt;
          border-top-style: solid;
          border-top-color: #000000;
      }
      td th table {
          width: 100%;
          vertical-align: center;
          text-align:center;
      }
      table {
          margin-top:auto;
          margin-right:auto;
          margin-bottom:auto;
          margin-left:auto;
          display:block;
      }

【问题讨论】:

  • 你解决过这个问题吗?我在尝试在多个页面上获得 周围的表格边框时遇到同样的问题
  • 不,抱歉 -- 项目进入保持亮灯模式

标签: html css django xhtml2pdf


【解决方案1】:

此答案与 Django 无关,仅与主题有关!

如果有人在这里结束,请记下:

支持的 CSS 属性

xhtml2pdf 支持以下标准 CSS 属性

背景色 边框底部颜色,边框底部样式,边框底部宽度 左边框颜色,左边框样式,左边框宽度 右边框颜色,右边框样式,右边框宽度 边框顶部颜色,边框顶部样式,边框顶部宽度 彩色显示 字体系列,字体大小,字体样式,字体粗细 高度 行高,列表样式类型 下边距、左边距、右边距、上边距 padding-bottom, padding-left, padding-right, padding-top 分页后,分页前 尺寸 文本对齐,文本装饰,文本缩进 垂直对齐 空白 宽度 放大

链接:reference

我花了一段时间才发现它不支持边框属性,而只支持边框-[上/左/右/下]-[样式/颜色/宽度]属性

【讨论】:

【解决方案2】:

您好@MilitaryCoo 尝试在您的表中添加border 属性,如下所示<table border="1"></table>

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签