Sonia1091 / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

End of PDF broken with page-break-before and many div (0.6.0 beta1) #184

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. With DOMPDF 0.6.0 beta1 (DOMPDF_ENABLE_REMOTE => true)
2. use the following HTML : http://pastebin.com/zbvN3dZg
3. with linked Stylesheet : http://pastebin.com/EaYDTkn6 (document.css head 
link)

What is the expected output? What do you see instead?

At the end of file we expect to have the "Contrib TEST 74 div" on a single Page 
and a last page contaning text "DISCLAIMER DISCLAIMER DISCL..."

But instead the "Contrib Test 74" is Broken on 3 pages and the Disclaimer Text 
is behind the broken div.

What version of the product are you using? On what operating system?
Using 0.6.0 beta1 runing on an xubuntu WebServer (apache2/php5)

Please provide any additional information below :

Found a bug wich may be linked with "page-break" style options bug.

After a certain number of div having "page-break-before: left;" the pdf broke 
all the HTML organisation. A div is split over 3 pages instead of being on a 
single one and the next content became a background of the broken pages

You can see on the attached PDF that the bug appears after the 10th page.

Original issue reported on code.google.com by sylvain....@gmail.com on 21 Sep 2010 at 2:18

Attachments:

GoogleCodeExporter commented 9 years ago
It seems to be due to the get_margin_height() function called into 
check_page_break 
Actually, the  check_page_break function use the get_margin_height() function 
wich returns margins + div height, to calculate if there is enough place to 
print a Frame. But it should only use the margins (and not the div height) of 
the containers to calculate it.

So the fix i found is :
Create the following function into frame.cls.php:

function get_break_margins(){
    return $this->_style->length_in_pt(array(/*$this->_style->height, -- NOT USED INTO Break checking*/
                                             $this->_style->margin_top,
                                             $this->_style->margin_bottom,
                                             $this->_style->border_top_width,
                                             $this->_style->border_bottom_width,
                                             $this->_style->padding_top,
                                             $this->_style->padding_bottom),
                                       $this->_containing_block["w"]);
  }

Then into frame_decorator : 

  function get_break_margins() { return $this->_frame->get_break_margins();}

Finally : 
into the file page_frame_decorator.cls.php 
near the line 445

replace  

$max_y = $frame->get_position("y") + $frame->get_margin_height();

by

$max_y = $frame->get_position("y") + $frame->get_break_margins();

I'm not really sure of what consequences it may have on the PDF generating, so 
if someone from the DOMPDF Team could validate i'm not wrong...

But for the moment it seems to work pretty good for the exemple file.

(I'm sorry if my english is a little poor, i'm a french guy)

Original comment by sylvain....@gmail.com on 22 Sep 2010 at 1:14

GoogleCodeExporter commented 9 years ago
Hello, sorry for the late reply, I tried the HTML and CSS you provided,and I 
have the same problem with the trunk, but, I don't know why this happens.
It seems that the height: 100% on #contributions is a part of the problem, but 
I don't know why.
It clearly is an annoying bug, I'm going to fix it.
By the way, I'm French too, so if you are still working on this project, I may 
help you easily ;)

Original comment by fabien.menager on 1 Feb 2011 at 9:50

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 24 May 2013 at 3:00