Weasyprint: Different page margin on first and subsequent pages

Created on 10 Oct 2019  路  2Comments  路  Source: Kozea/WeasyPrint

Hello,

I noticed that first and subsequent pages have different top margins. Difference is about 2mm. I am not sure if this is bug or something else.

Below is reproducible test case and PDF created with that script is in attachment test-page-top-margin.pdf

from weasyprint import HTML

main_html = """<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width" />
    <style>
@page {
  margin: 10mm;
  size: A4 landscape;
}
.page-fp__header {
  height: 80mm;
  border: 1px solid #000;
  page-break-before: always;
}
    </style>
  </head>
  <body>

          <div class="page-fp__header">
              CONTENT 1
          </div>
          <div class="page-fp__header">
              CONTENT 2
          </div>
          <div class="page-fp__header">
              CONTENT 4
          </div>

</body>
</html>
"""


if __name__ == "__main__":
    HTML(string=main_html).write_pdf("test-page-top-margin.pdf")

Most helpful comment

It's the <body> having a (default) margin of 8 pixels. The top and bottom margins are suppressed when a box is split across pages.
You can either give the body a margin: 0 or (to sustain the margins on each page) a box-decoration-break: clone

All 2 comments

It's the <body> having a (default) margin of 8 pixels. The top and bottom margins are suppressed when a box is split across pages.
You can either give the body a margin: 0 or (to sustain the margins on each page) a box-decoration-break: clone

Thanks and sorry for the noise.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjbeyeler picture mjbeyeler  路  4Comments

antuaneacion picture antuaneacion  路  3Comments

bjornasm picture bjornasm  路  3Comments

ajakubo1 picture ajakubo1  路  5Comments

assuntaw picture assuntaw  路  3Comments