如何在页面中显示第一行而不截断

时间:2016-09-25 10:11:17

标签: css html5 pdf pdf-generation wkhtmltopdf

某些网页wkhtmltopdf会截断PDF中的第一行:

partial

线条的高度与其他线条相同:

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

             html, body {
                height: 100%;
                width: 100%;
            }

            .row {
                position: relative;
                clear: both;
            }

            .field {
                font-family: "Times New Roman";
                font-size: 10pt;
                background-color: transparent;
                overflow: hidden;
                word-break: break-all;
                z-index: 2;
            }
   </head><body>
    ....
    <div class='row'><div class='field' style='left:0.13cm;width:3.37cm;height:0.47cm;text-align:right;color:#000080;'>POS sale 136287</div>
    </div>
    <div class='row'><div class='field' style='left:3.68cm;width:1.82cm;height:0.47cm;'>30.01.2016</div>
    </div>
    <div class='row'><div class='field' style='left:5.55cm;width:4.45cm;height:0.47cm;'> Jaeostja </div>
    </div>
    <div class='row'><div class='field' style='left:10.03cm;width:2.53cm;height:0.47cm;text-align:right;'>0,15</div>
    </div>
    <div class='row'></div><div class='row'><div class='field' style='left:15.05cm;width:2.47cm;height:0.47cm;text-align:right;'>-26730,47</div>
  ...

要重现的完整html位于

https://github.com/wkhtmltopdf/wkhtmltopdf/files/491556/partialline2.zip

结果pdf位于https://github.com/wkhtmltopdf/wkhtmltopdf/files/491558/result.zip

如何用pdf显示整行?

我尝试添加

page-break-inside: avoid !important;
margin: 4px 0 4px 0;  /* to keep the page break from cutting too close to the text in the div */

avoid page break inside row of table

中描述的行和字段类

但问题仍然存在。

  • wkhtmltopdf版本:0.12.2.1(也出现在0.12.3.2中)
  • 操作系统:Windows 10 Pro 1511

也在https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3141

中发布

0 个答案:

没有答案