Welcome Guest Search | Active Topics | Sign In | Register

BUG: If html-element is in line with thead it will be also repeated on every page of PDF where thead is rendered Options
enliberte
Posted: Monday, January 20, 2020 9:19:31 AM
Rank: Newbie
Groups: Member

Joined: 1/10/2020
Posts: 1
If html-element is in line with thead it will be also repeated on every pdf page where thead is rendered.

To convert html to pdf I use HtmlToPdf.ConvertHtml method.

You can use the following html to reproduce such a bug:

Code: HTML/ASPX
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .container {
                display: flex;
            }
    
            table {
                flex: 1;
                table-layout: fixed;
            }
    
            .some_block {
                flex: 1;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div></div>
            <table>
                <thead>
                    <td>THEAD</td>
                </thead>
                <tbody>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                    <tr><td>A</td></tr>
                </tbody>
            </table>
            <div class="some_block">
                <span>11111111111111111111111</span>
            </div>
        </div>
    </body>
</html>


Span content (11111111111111111111111) is on the top of every page.
eo_support
Posted: Monday, January 20, 2020 2:51:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

This is a known restriction in the current implementation. The repeating is a result of the auto repeating table header/footer feature (controled by HtmlToPdf.Options.RepeatTableHeaderAndFooter) and this is a paging feature. A paging feature can not change contents layout because paging process occurs after the layout process.

The subtle implication that paging can not change contents layout is that the same contents will occur exactly the same before and after paging process. So if "1111" appears next to the table header in this case before the paging, it will be exactly the same after the paging -- and by extension, it will be exactly the same on every page.

Technically it is possible for us to modify the browser engine's layout/drawing code extensively to distinguish this case but it would involve significantly code changes and it would open the door to numerous non-standard layout interpretations. Thus we have decided against it.

To avoid this issue, you can either set HtmlToPdf.Options.RepeatTableHeaderAndFooter to false, or modify your HTML layout to avoid other contents at the same vertical location as a table header/footer.

Hope this helps. Please feel free to let us know if you still have any more questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.