UIWebView无法检测分页符

时间:2016-12-23 16:57:04

标签: html ios css swift uiwebview

我想从webview.viewPrintformattor打印文档,但分页符在UIwebview中不起作用。请查看下面的CSS。

<style type="text/css">
@media print {
.page-break {
    display: block;
    page-break-after: always;
}
@page {
    size: A4 portrait; /* can use also 'landscape' for orientation */
    margin: 0.5in;
    padding: 1em;
}

}
body {
    font-family: calibri, arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #000000;
}
h1, h2, h3 {
    margin: 0;
    padding: 0;
}
td {
    vertical-align: top;
}
.ar {
    direction: rtl;
    text-align: justify;
}
.page-break {
    display: block;
    page-break-after: always;
}
@page {
    size: A4 portrait; /* can use also 'landscape' for orientation */
    margin: 0.5in;
    padding: 1em;
}
</style>

并使用以下代码进行分页。

 <div class="page-break"></div> 

1 个答案:

答案 0 :(得分:0)

http://www.w3schools.com/cssref/pr_print_pagebb.asp

定义和用法 page-break-before属性设置是否应在指定元素之前发生分页符。

注意:您不能在空<div>或绝对定位的元素上使用此属性。