wkhtmltopdf - wkhtml2pdf 可以支持 CSS 计数器吗?

标签 wkhtmltopdf

我的计数器重置和计数器增量在 HTML 中工作正常,但它们没有出现在呈现的 PDF 中。他们支持吗? (一个小时的谷歌搜索没有帮助。)

这是我的 CSS。同样,这在 HTML 中工作正常,但不会出现在 PDF 中。

body {
 counter-reset: h3counter 1;
 counter-reset: h4counter 1;
}

h2 {
  counter-reset: h3counter;
}

h3 {
  counter-increment: h3counter;
  counter-reset: h4counter;
}

h3:before {
  content: counter(h3counter) ".\0000a0\0000a0";
}

h4 {
  counter-increment: h4counter;
}

h4:before {
  content: counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0";
}

最佳答案

是的,它有效(在 wkhtmltox.dll 版本 0.11.0.0 中),但仅适用于简单情况。我刚刚遇到了当标题标签(h1、h2、h3)不是直接兄弟时计数器似乎重置的问题 - 即每个都包含在一个 div 中。当标题相邻时,如:

<h2>..</h2>
<h3>...</h3>
<h3>...</h3>

wkhtmltopdf 数字正确;在这种情况下:
<h2>...</h2>
<div>
  <h3>...</h3>
</div>
<div>
  <h3>...</h3>
</div>

它不是。两个 h3 得到相同的数字。

关于wkhtmltopdf - wkhtml2pdf 可以支持 CSS 计数器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28573520/

相关文章:

ruby-on-rails - wicked_pdf 不在 Ubuntu 服务器上运行 : wkhtmltopdf: cannot connect to X server

ubuntu - 更新后 Wkhtmltopdf 字体大小增加

docker - 库 wkhtmltopdf 在 Docker 中不工作

php - 服务器上活泼的 wkhtmltopdf 的二进制路径

.net - 部署到服务器上的 IIS 后,Rotativa pdf 无法工作

node.js - AWS Lambda NodeJS12.x - 加载共享库时出错 : libXrender. so.1

asp.net-mvc - Rotativa/Wkhtmltopdf图像不显示

azure - Rotativa、ABCPdf 和 EO.Pdf 在 Azure 网站中不起作用,我不想升级到 Azure "Cloudapp"

javascript - SVG ClipPath 不适用于 wkhtmltopdf

pdf-generation - 使用wkhtmltopdf时如何设置目录的位置