danfickle / danfickle/openhtmltopdf

Wrong box sizing

Open
#865 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Hi folks,
    we are experiencing problems trying to render a box whose size, plus margins, fits exactly in the page.
    The resulting pdf file hasn't one single page but 2.

    Page size is `A6` (`105mm X 148mm`).
    Box size is `85mm X 128mm` plus `10mm` margin on each side.

    As a workaround we can set bottom margin to `9.999px` or `9.990mm`, but would be nice to have the box to fit without the workaround.

    Thanks
    Ivan

[sample pdf output](https://github.com/danfickle/openhtmltopdf/files/9469056/test_A6_fail.pdf)

**HTML to test on _`sandbox.openhtmltopdf.com`_**
```



@page {
/* 2 values: width then height */
size: 105.0mm 148.0mm;
margin: 0.0mm 0.0mm 0.0mm 0.0mm;
}

body {
margin: auto;
}

.content {
width: 85.0mm;
height: 128mm;
margin: 10.0mm 10.0mm 10.0mm 10.0mm;
float: left;
/*
uncomment below to get rid of extra blank page
*/
/*margin-bottom: 9.999px;*/
}



/*debug*/
html {
background-color: blue;
}

body {
background-color: pink;
}

.content {
background-color: orange;
}

Test A6



CONTENT

```
**Sandbox call to reproduce the issue**
```
curl 'https://sandbox.openhtmltopdf.com/post-pdf' -o test_A6.pdf \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'upload-area=%3C%21DOCTYPE+html%3E%0D%0A%3Chtml%3E%0D%0A%09%3Chead%3E%0D%0A%09%09%3Cstyle+type%3D%22text%2Fcss%22+media%3D%22print%22%3E%0D%0A%09%09%09%40page+%7B%0D%0A%09%09%09%09%2F*+2+values%3A+width+then+height+*%2F%0D%0A%09%09%09%09size%3A+105.0mm+148.0mm%3B%0D%0A%09%09%09%09margin%3A+0.0mm+0.0mm+0.0mm+0.0mm%3B%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09body+%7B%0D%0A%09%09%09%09margin%3A+auto%3B%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09.content+%7B%0D%0A%09%09%09%09width%3A+85.0mm%3B%0D%0A%09%09%09%09height%3A+128mm%3B%0D%0A%09%09%09%09margin%3A+10.0mm+10.0mm+10.0mm+10.0mm%3B%0D%0A%09%09%09%09float%3A+left%3B%0D%0A%09%09%09%09%2F*%0D%0A%09%09%09++++++++++++uncomment+below+to+get+rid+of+extra+blank+page%0D%0A%09%09%09++++++++*%2F%0D%0A%09%09%09%09%2F*margin-bottom%3A+9.999px%3B*%2F%0D%0A%09%09%09%7D%0D%0A%09%09%09%3C%2Fstyle%3E%0D%0A%09%09%09%0D%0A%09%09%09%3Cstyle+type%3D%22text%2Fcss%22%3E%0D%0A%09%09%09%2F*debug*%2F%0D%0A%09%09%09html+%7B%0D%0A%09%09%09%09background-color%3A+blue%3B%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09body+%7B%0D%0A%09%09%09%09background-color%3A+pink%3B%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09.content+%7B%0D%0A%09%09%09%09background-color%3A+orange%3B%0D%0A%09%09%09%7D%0D%0A%09%09%3C%2Fstyle%3E%0D%0A%09%09%3Ctitle%3ETest+A6%3C%2Ftitle%3E%0D%0A%09%3C%2Fhead%3E%0D%0A%09%3Cbody%3E%0D%0A%09%09%3Cdiv+class%3D%22content%22%3E%0D%0A%09%09%09%3Cspan%3ECONTENT%3C%2Fspan%3E%0D%0A%09%09%3C%2Fdiv%3E%0D%0A%09%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E' \
--compressed
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.