html - 使用 wkhtmltopdf 时如何在不显示 <h*> 标签的情况下将文档分成几个部分?

标签 html css pdf webkit wkhtmltopdf

我正在使用 wkhtmltopdf 实现目录.

为了生成目录,我必须将标签放在文档中,如 documentation 中所述:

The table of content is generated based on the H tags in the input documents. First a XML document is generated, then it is converted to HTML using XSLT.

出于产品设计的原因,我需要这样做,以便在最终的 PDF 中既不显示也不占用空间。

我尝试使用绝对定位并使用“透明”颜色来隐藏文本,但有时效果不佳,因为 wkhtmltopdf 将它们排除在目录之外。我猜 webkit 引擎优化了它们。

是否有可能以某种方式“标记”内容而不是包含实际的 HTML 标记?

谢谢

最佳答案

我实际上使用隐藏的<h*>成功。但是绝对定位对我也不起作用。这是隐藏大纲标题的样式:

width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: 0 -1px -1px 0 !important;
overflow: hidden !important;
opacity: 0 !important;

诀窍是让标题具有实际大小(1x1 像素),用不透明度隐藏它们并避免它们占用 1px 的空间和负边距。

Is it possible to somehow "tag" the content instead of including the actual HTML tags?

我不这么认为。

关于html - 使用 wkhtmltopdf 时如何在不显示 <h*> 标签的情况下将文档分成几个部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39327456/

相关文章:

javascript - 如何通过添加子项使 div 溢出时可滚动

css - 在网页上加载自定义 html 和 css?

php - CSS 中的命名空间/作用域

html - 最小化页面时如何使我的网页响应

javascript - 两个不同的 Bootstrap 菜单在同一个按钮上折叠

javascript - $(window).width() 没有正确给出视口(viewport)宽度

c# - 使用 iTextSharp 为 PDF 中的图像添加透明度/不透明度

html - li之间的导航栏间距

c# - 有什么方法可以将 PDF 字节数组的一部分转换为单独的 PDF 文件吗?

javascript - 从 api 响应中获取 pdf 文件