rvpatel / dompdf

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

body background incorrectly cropped to the size of the content box #550

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I need to have a full background image (to the edge of the page) and I need a 
way to properly set the content to specific margins across all of the pages 
from the PDF. I am very close to do it except from one annoying bug.

CSS:

html {
margin: 0px;
}

So the page has no margin

body {
background-image: /* I am using a red background image that matches the height 
and width of the page */
background-repeat: no-repeat;
padding: 100px 100px 100px 100px;
}

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

With this I would expect to see the background properly displayed on the full 
page and the content of the page taking into account the padding of the body. 
What is happening is that the padding affect the content just fine, but both 
the padding-top and padding-bottom parts of the CSS is making the bottom part 
of the image not to be displayed. The bottom part is actually blank, and this 
blank height is the sum of the padding-top and padding-bottom elements. The 
right and left seems to work just fine with both the content and the image.

I tried to do this as well with margin instead of padding. Margin in the body 
affects the margin of the background image, so that's doesn't work for me. I 
tried to use a main div "content" to hold the content and add margin to that, 
and it works for all expect for the margin-top, which works only on the first 
page. If the content is spread on multiple pages the margin top doesn't change 
on any other pages than the first.

What version of dompdf are you using? What version of PHP? On what
operating system?

0.6 beta3 as well as trunk. PHP 5.3.18, linux debian testing

Please provide the HTML source code you want to convert, or any additional
information.

Tried to explain it above, I can create a sample HTML if necessary.

Original issue reported on code.google.com by abar...@gmail.com on 1 Nov 2012 at 7:05

GoogleCodeExporter commented 9 years ago
related to issue 551

Original comment by abar...@gmail.com on 1 Nov 2012 at 7:22

GoogleCodeExporter commented 9 years ago
There does appear to be an issue here. As you say, the background is being 
cropped to a height based on the content box instead of the border box. 
Otherwise, placement appears to be correct.

Original comment by eclecticgeek on 5 Nov 2012 at 3:50

GoogleCodeExporter commented 9 years ago
I hope you get to look into this rather soon, probably not a hard fix? If you 
can point me in some direction within the code I might be interested in 
helping, I tried but really couldn't my my way through the code quickly enough.

thanks.

Original comment by abar...@gmail.com on 5 Nov 2012 at 9:48

GoogleCodeExporter commented 9 years ago
Well, I took a crack at it and I think I sorted it, attached is patch, pretty 
simple IMHO.

Patch is against trunk.

Basically the height of the background image is substracted by the margins, 
paddings and border width, I believe only the margin and border width has to be 
taken into account, not padding.

Original comment by abar...@gmail.com on 7 Nov 2012 at 2:26

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for this patch! We'll review it as soon as wee can.

Original comment by fabien.menager on 14 Nov 2012 at 9:27

GoogleCodeExporter commented 9 years ago

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