Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf page-break-before is off by one? Options
Ryan
Posted: Thursday, May 22, 2014 5:17:03 PM
Rank: Member
Groups: Member

Joined: 3/25/2014
Posts: 11
Using EO.Pdf 5.0.76.2

I'm using the page-break-before style to cause page breaks in a grid of data. You can see the original page here:

https://dl.dropboxusercontent.com/s/0la9stduvkqnb05/test-page-break.html

If you plug this page into the live demo here: http://www.essentialobjects.com/Products/EOPdf/UrlToPdf.aspx

You'll get a pdf with the page break off by one row. I'm expecting the "First" and "Second" headers to be at the top of the page, but there is another line in there. If you debug the page, you can see the style is on the div. Am I missing something?

Thanks

eo_support
Posted: Saturday, May 24, 2014 12:09:48 AM
Rank: Administration
Groups: Administration

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

We have looked into your page. The problem has to do with how your rows are arranged. Specifically, a combination of the font, height and margin settings caused the rectangle of the last line of text before the page break header row and the page break header row to overlap. The following example demonstrates how this can affect the paging process:

1. Text in the previous row top and bottom position (top = 100, bottom = 120)
2. Row with page-break-before: always (top = 118, bottom = 138)

In this case, if the converter were to break at 118 as requested by the "page-break-before: always", then the text in the previous line would be cut off at y = 118 because the full text height extends to 120. For this reason the pager decided to extend the page-break position to cover the whole line of text to 100. Keep in mind that paging process can not rearrange element positions ---- it only decides where to cut.

The easiest way to avoid this problem is to add some additional top margins on your page-break-before:always row. For example:

Code: HTML/ASPX
<div class="ax-row ax-row-header" style="page-break-before:always;margin-top:5px;" ....>
    .....
</div>


Here the additional margin added to this row will add enough space between this row and the text in the previous row so that they won't overlap. As soon as overlap does not occur, the paging process will be able to precisely honor your page-break-before: always instruction.

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

Thanks!
Ryan
Posted: Tuesday, May 27, 2014 10:26:34 AM
Rank: Member
Groups: Member

Joined: 3/25/2014
Posts: 11
This worked. Thanks for the tip.

As you can see, I have a grid of data that will be multiple pages. I'd like to have this grid's header repeat on each page. Is there any support for getting the height of the page from the EO object in javascript? I'd like to dynamically compute where to add the page-break-before style.

Or do you suggest a different way of getting the grid header row on the top of each page? HtmlToPdf.Options.HeaderHtmlFormat didn't seem like it will work for me. I don't readily have the grid info on the c# side, and it's hard to get it formatted to match up to my grid data.

Thanks
eo_support
Posted: Tuesday, May 27, 2014 10:41:14 AM
Rank: Administration
Groups: Administration

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

The easiest way is to use a html table. See here for more details:

http://www.essentialobjects.com/doc/4/htmltopdf/table_header.aspx

While it's possible for you to get element height with JavaScript, you can't use JavaScript to do this kind of layout adjustment. Paging occurs after the page has been rendered. So at that stage you can't rearrange anything.

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.