为什么 wkhtmltopdf page-break-after 没有任何效果? [英] Why doesn't wkhtmltopdf page-break-after have any effect?

查看:48
本文介绍了为什么 wkhtmltopdf page-break-after 没有任何效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 wkhtmltopdf 0.10.0 rc2 for Mac

我有一个这样的 html :

<html lang="zh-cn"><头><meta charset="utf-8"><link href="print.css" rel="stylesheet"><style type="text/css" media="screen,print">.休息{显示:块;清楚:两者;分页后:总是;边框:1px 纯红色}.分页符{显示:块;分页后:总是;边框:1px 纯红色}</风格><身体><div class="container break">第 1 页

<div class="page-breaker"></div><div class="容器">第2页

</html>

我只是尝试:

wkhtmltopdf test.html test.pdf

但它没有产生分页符,我做错了什么?

解决方案

可能无关,因为您的 pdf 与较早版本的 wkhtmltopdf 生成正常.无论哪种方式,我都有类似的问题,即未正确应用分页符.我的问题是分页元素的父元素具有除 visible 之外的 overflow.这解决了我的问题:

* {溢出:可见!重要;}

当然,您可以更具体地了解这适用于哪些标签;)

I'm using wkhtmltopdf 0.10.0 rc2 for Mac

I have an html like this one :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link href="print.css" rel="stylesheet">
    <style type="text/css" media="screen,print">
      .break{
        display: block;
        clear: both;
        page-break-after: always;
        border :1px solid red
      }
      .page-breaker {
      display: block;
      page-break-after: always;
      border :1px solid red
      }
    </style>
  </head>
  <body>
    <div class="container break">
      page 1
    </div>
    <div class="page-breaker"></div>
    <div class="container">
      page 2
    </div>
  </body>
</html>

I simply try :

wkhtmltopdf test.html test.pdf

But it didn't produce a page-break, I doing something wrong ?

解决方案

Possibly unrelated as your pdf generated ok with an earlier version of wkhtmltopdf. Either way, I had similar issues with page breaks not being applied correctly. My problem was parent elements of the page-breaked element having an overflow other than visible. This fixed my issue:

* {
  overflow: visible !important;
}

Of course, you can be more specific about the tags this applies to ;)

这篇关于为什么 wkhtmltopdf page-break-after 没有任何效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆