wkhtmltopdf解决分页问题

简介:

wkhtmltopdf 有个很好的方法,就是在那个div的样式后添加一个:page-break-inside:avoid;就ok了。

复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>pdf</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style type="text/css">
*{ margin:0px; padding:0px;}
div{ width:800px; min-height:1362px;margin:auto;page-break-inside:avoid;}
</style>
<body>
<div style=" background:#030"></div>
<div style=" background:#033"></div>
<div style=" background:#369"></div>
<div style=" background:#F60"></div>
<div style=" background:#F3C"></div>
<div style=" background:#F0F"></div>
<div style=" background:#0FF"></div>
<div style=" background:#FF0"></div>
<div style=" background:#00F"></div>
<div style=" background:#0F0"></div>
<div style=" background:#033"></div>
<div style=" background:#369"></div>
<div style=" background:#F60"></div>
<div style=" background:#030"></div>
<div style=" background:#033"></div>
<div style=" background:#369"></div>
<div style=" background:#F60"></div>
<div style=" background:#F3C"></div>
<div style=" background:#F0F"></div>
<div style=" background:#0FF"></div>
<div style=" background:#FF0"></div>
<div style=" background:#00F"></div>
<div style=" background:#0F0"></div>
</body>
</html>


本文转自黄聪博客园博客,原文链接:http://www.cnblogs.com/huangcong/p/5526316.html,如需转载请自行联系原作者
相关文章
|
9月前
|
XML 存储 安全
Excel电子表格的PHP类库:PHP_XLSXWriter(大数据量报表、后台运行、浏览器下载)
Excel电子表格的PHP类库:PHP_XLSXWriter(大数据量报表、后台运行、浏览器下载)
158 0
|
7月前
|
PHP
PHP 文件加载简单使用
PHP 文件加载简单使用
42 0
|
PHP
PHP:laravel自定义分页page查询方法
PHP:laravel自定义分页page查询方法
88 0
|
JavaScript 前端开发 Java
html页面导出为pdf(jsPDF、iText、wkhtmltopdf)
html页面导出pdf,本来是一件很简单的事情,在浏览器直接打印(Mac快捷键为⌘+p;Windows快捷键为ctrl+p),就可以把页面另存为pdf文件,但对于要经常把页面导出为pdf的用户来说并不友好,一个合格程序员的标准就是:做出来的软件猪都要会用,否则你就是猪。 调研了几种html导出pdf的实现方式,这里把要点记录下来分享下。
html页面导出为pdf(jsPDF、iText、wkhtmltopdf)
|
PHP SQL
php分页数据最后一页继续追加第一页数据
之前做数据分页遇到这样一个需求,就是数据到最后一页的时候不能中断,继续把第一页的数据追加到后面,无限显示下去。 原文地址:代码汇个人博客 http://www.codehui.net/info/23.
1012 0
|
JavaScript 前端开发 PHP