xhtml2pdf子元素显示父元素的边框

时间:2014-10-21 16:20:49

标签: python css xhtml2pdf

希望有人可能已经解决了这个问题。在谷歌上没见过有人。

我在Python中使用xhtml2pdf,尝试使用页眉,页脚生成一个简单的文档,我的内容是带有标题的文本块。我想在每个内容周围都有一个边框,但我会在每个子元素周围找到边框。

这是我的HTML

@page {
  size: letter;
  border: 0;
  @frame header_frame {
    -pdf-frame-content: header;
    border: 0pt solid white;
    left: .75in;
    width: 7in;
    top: .5in;
    height: 1.5in;
  }
  @frame content_frame {
    border: 0pt solid white;
    left: .75in;
    width: 7in;
    top: 1.5in;
    height: 7.5in;
  }
  @frame footer_frame {
    -pdf-frame-content: footer;
    border: 0pt solid white;
    left: .75in;
    width: 7in;
    top: 9.5in;
    height: 1in;
  }
}

h1 {
  padding-top: 5pt;
}

.desc {
  margin-top: 3px;
  margin-bottom: 3px;
  padding: 3px;
  border: 1px solid blue;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
  <title>TEST TEST TEST</title>
</head>

<body>
  <div id="header">
    <h1>HEADER</h1>
  </div>
  <div id="footer">
    FOOTER
  </div>
  <div class="desc">
    <div class="title">TITLE OF ARTICLE</div>
    <span>TEST 2</span>
    <div>TEST 3</div>
    <table>
      <tr>
        <td>Test4</td>
        <td>Test 5</td>
      </tr>
    </table>
  </div>
</body>

</html>

我现在只是运行xhtml2pdf命令行工具,因此无法显示python。我在调试模式下运行它时注意到的一件事是它显示“xhtml = false”,即使我有一个XHTML DTD。我不确定这是否会产生影响。

这是我在浏览器中看到的内容以及我希望pdf看起来的内容(当然忽略页脚位置):

expected output

相反,我得到:

enter image description here

编辑:我发现xhtml是一个传递选项,但传递它失败,除非安装了旧版本的html5lib。看起来我的问题的答案是这个库没有得到积极维护,我需要找到一个新的解决方案: - /

0 个答案:

没有答案
相关问题