Python xhtml2pdf table 单元格文本显示为垂直

Python xhtml2pdf table cell text display to vertical

我正在使用 xhtml2pdf 在 Django 中生成报告,我想让我的单元格文本之一垂直显示,但我无法使用 css。

这是一些尝试:

.vertical-text {
     writing-mode: tb-rl; 
}

<table>
    <tbody>
        <tr>
            <td class="vertical-text" >V text</td>
        </tr>
    </tbody>
</table>

UPDATE

writing-mode 属性 在 supported css properties 中丢失。有什么解决方法吗?

还有另一种解决方法,我们可以使用 css:JSFiddle

.verical-text {
    width:1px;
    font-family: monospace;
    white-space: pre-wrap; /* this is for displaying whitespaces including Firefox */
}

但是,这里有几个缺点:

  1. 字母之间是否必须有 空格 以确保其垂直显示。
  2. 字母未旋转,但方向相似。

我建议使用其他工具,这样您就不会受到 css 属性的限制,例如:

  • PhantomJs - 在后端编写一个自定义的 nodeJs 服务器来完成它。