wkhtmltopdf/wkhtmltopdf

Page first line is truncated sometimes in PDF

Closed this issue · 13 comments

In some pages first line in created PDF is truncated:

partiallineintopofpage

Line has proper height like other lines:

<!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>
Full html to reproduce: [partialline2.zip](https://github.com/wkhtmltopdf/wkhtmltopdf/files/491556/partialline2.zip)

Result pdf:
result.zip

wkhtmltopdf Version: 0.12.2.1 (occurs in 0.12.3.2 also)
Operating System and Version: Windows 10 Pro 1511

I tried to add

page-break-inside: avoid !important;
margin: 4px 0 4px 0;

to row and field classes as described in http://stackoverflow.com/questions/9288802/avoid-page-break-inside-row-of-table/17982110#17982110

but problem persists.

Posted also in http://stackoverflow.com/questions/39685685/how-to-show-first-line-in-page-without-truncation

@kobruleht i have seen your html structure you made it using position could you try to make it using float.I have tried it, and text does not cut.
Updated file:
partialline.zip

html is generated automatically from report layout. Report layout contains fields with absolute positions . It is difficult to re-factor existing code to fix wkhtmltopdf issue. Looking for solution so that html markup remains same. Styles can changed.

If you can avoid overflow:hidden, that might fix the issue.

Thank you. Users can draw boxes with any size in designer. Data which is coming to this box from database may be bigger than fits to box.
In this case data which does not fit to div should not displayed. So aviding overflow:hidden is bit difficult: application shoud calculate how must text fix to box and not send more text. No idea how to implement this.

I removed overflow:hidden from style. First line in some pages is still incorrect:

truncated

If overflow:hidden is used, first line is truncated bit more:

more

Hello Is Any One got Solution of this issue...Replay me

looking forward to solutions for this problem.

Me too.. :-(

The same issue

same issue

same issue

Duplicate of #1524, #2141.
Please read these issues. You can find some workarounds that can improve a situation, since there is no real fix yet.

Adding
html, body { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; }

Fixed it for me.